forked from guillermooo/dart-sublime-bundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
polymer.py
66 lines (49 loc) · 2.1 KB
/
polymer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) 2014, Guillermo López-Anglada. Please see the AUTHORS file for details.
# All rights reserved. Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.)
import sublime
import sublime_plugin
import os
from Dart.lib.pub_package import PubPackage
from Dart.lib.base_cmds import PolymerCommand
from Dart.sublime_plugin_lib import PluginLogger
_logger = PluginLogger(__name__)
# TODO(guillermooo): try adding is_active or whatever method returns
# availability status.
class DartGeneratePolymerElementCommand(PolymerCommand):
'''
pub run polymer:new_element
'''
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def run(self):
super().run('Element Name:')
def on_done(self, name):
view = self.window.active_view()
project = PubPackage.from_path(view.file_name())
cmd = "pub run polymer:new_element {} -o \"{}\""
# TODO(guillermooo): we cannot access the ouput panel used by exec.
# This means we cannot print friendlier status output. Replace exec
# with our own async process execution so that we can control its
# output panel.
self.execute(cmd.format(name, self.get_target_path(view)),
project.pubspec.parent)
# TODO(guillermooo): try adding is_active or whatever method returns
# availability status.
class DartAddPolymerEntryPointCommand(PolymerCommand):
'''
pub run polymer:new_entry
'''
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def run(self):
super().run('Entry Point Name:')
def on_done(self, name):
view = self.window.active_view()
project = PubPackage.from_path(view.file_name())
cmd = "pub run polymer:new_entry {}".format(name)
# TODO(guillermooo): we cannot access the ouput panel used by exec.
# This means we cannot print friendlier status output. Replace exec
# with our own async process execution so that we can control its
# output panel.
self.execute(cmd, project.pubspec.parent)