Skip to content

Commit 740c601

Browse files
added @angular/cling generate
1 parent 45a4386 commit 740c601

File tree

8 files changed

+126
-48
lines changed

8 files changed

+126
-48
lines changed

_generated_2017_12_28_at_21_53_50.py renamed to _generated_2017_12_29_at_01_42_12.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ def prepare_command(self, **kwargs):
18201820
self._run()
18211821

18221822
def platform_on_done(self, platform):
1823-
self.placeholders[":platform"] = shlex.quote(platform)
1823+
self.placeholders[":platform"] = shlex.quote(platform.strip())
18241824
self.command = self.substitute_placeholders(self.command)
18251825
self._run()
18261826

@@ -1916,7 +1916,7 @@ def prepare_command(self, **kwargs):
19161916
self._run()
19171917

19181918
def platform_on_done(self, platform):
1919-
self.placeholders[":platform"] = shlex.quote(platform)
1919+
self.placeholders[":platform"] = shlex.quote(platform.strip())
19201920
self.command = self.substitute_placeholders(self.command)
19211921
self._run()
19221922

@@ -2014,7 +2014,7 @@ def prepare_command(self, **kwargs):
20142014
self._run()
20152015

20162016
def platform_on_done(self, platform):
2017-
self.placeholders[":platform"] = shlex.quote(platform)
2017+
self.placeholders[":platform"] = shlex.quote(platform.strip())
20182018
self.command = self.substitute_placeholders(self.command)
20192019
self._run()
20202020

@@ -2102,13 +2102,13 @@ class angularv1_cliCommand(manage_cliCommand):
21022102

21032103
def prepare_command(self, **kwargs):
21042104

2105-
if self.command[0] in ["angular:controller", "angular:directive", "angular:filter", "angular:route", "angular:service", "angular:provider", "angular:factory", "angular:value", "angular:constant", "angular:decorator", "angular:view"]:
2105+
if ":name" in self.command:
21062106
sublime.active_window().show_input_panel( (self.command[0].replace("angular:", ""))+" name:", "", self.name_on_done, None, None )
21072107
else :
21082108
self._run()
21092109

21102110
def name_on_done(self, name):
2111-
self.placeholders[":name"] = shlex.quote(name)
2111+
self.placeholders[":name"] = shlex.quote(name.strip())
21122112
self.command = self.substitute_placeholders(self.command)
21132113
self._run()
21142114

@@ -2191,29 +2191,34 @@ class angularv2_cliCommand(manage_cliCommand):
21912191

21922192
def prepare_command(self, **kwargs):
21932193

2194-
# if self.command[0] in ["angular:controller", "angular:directive", "angular:filter", "angular:route", "angular:service", "angular:provider", "angular:factory", "angular:value", "angular:constant", "angular:decorator", "angular:view"]:
2195-
# sublime.active_window().show_input_panel( (self.command[0].replace("angular:", ""))+" name:", "", self.name_on_done, None, None )
2196-
# else :
2197-
# self._run()
2198-
2199-
self._run()
2194+
if ":name_and_options" in self.command:
2195+
sublime.active_window().show_input_panel( self.command[0] + " " + self.command[1] + " name and options:", "", self.name_and_options_on_done, None, None )
2196+
else :
2197+
self._run()
22002198

2201-
def name_on_done(self, name):
2202-
self.placeholders[":name"] = shlex.quote(name)
2199+
def name_and_options_on_done(self, name_and_options):
2200+
self.placeholders[":name_and_options"] = name_and_options.strip()
22032201
self.command = self.substitute_placeholders(self.command)
22042202
self._run()
22052203

22062204
def _run(self):
2207-
# try:
2208-
# self.command = {
2209-
# 'serve': lambda : self.command + self.settings["angularv2_settings"]
2210-
# }[self.command[0]]()
2211-
# except KeyError as err:
2212-
# pass
2213-
# except Exception as err:
2214-
# print(traceback.format_exc())
2215-
# pass
22162205

2206+
try:
2207+
self.command = {
2208+
'build': lambda : self.command + self.settings["angularv2_settings"]["platform_run_options"][self.command[2].replace('--', '')],
2209+
'serve': lambda : self.command + self.settings["angularv2_settings"]["serve_options"],
2210+
'lint': lambda : self.command + self.settings["angularv2_settings"]["lint_options"],
2211+
'test': lambda : self.command + self.settings["angularv2_settings"]["test_options"],
2212+
'e2e': lambda : self.command + self.settings["angularv2_settings"]["e2e_options"],
2213+
'eject': lambda : self.command + self.settings["angularv2_settings"]["eject_options"],
2214+
'xi18n': lambda : self.command + self.settings["angularv2_settings"]["xi18n_options"]
2215+
}[self.command[0]]()
2216+
except KeyError as err:
2217+
pass
2218+
except Exception as err:
2219+
print(traceback.format_exc())
2220+
pass
2221+
22172222
super(angularv2_cliCommand, self)._run()
22182223

22192224

project/angularv1/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class angularv1_cliCommand(manage_cliCommand):
6262

6363
def prepare_command(self, **kwargs):
6464

65-
if self.command[0] in ["angular:controller", "angular:directive", "angular:filter", "angular:route", "angular:service", "angular:provider", "angular:factory", "angular:value", "angular:constant", "angular:decorator", "angular:view"]:
65+
if ":name" in self.command:
6666
sublime.active_window().show_input_panel( (self.command[0].replace("angular:", ""))+" name:", "", self.name_on_done, None, None )
6767
else :
6868
self._run()
6969

7070
def name_on_done(self, name):
71-
self.placeholders[":name"] = shlex.quote(name)
71+
self.placeholders[":name"] = shlex.quote(name.strip())
7272
self.command = self.substitute_placeholders(self.command)
7373
self._run()
7474

project/angularv2/Main_disabled.sublime-menu

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,74 @@
1414
"command": ["serve"]
1515
}
1616
},
17+
{
18+
"caption": "Generate",
19+
"children": [
20+
{
21+
"caption": "Class",
22+
"command": "angularv2_cli",
23+
"args": {
24+
"command": ["generate", "class", ":name_and_options"]
25+
}
26+
},
27+
{
28+
"caption": "Component",
29+
"command": "angularv2_cli",
30+
"args": {
31+
"command": ["generate", "component", ":name_and_options"]
32+
}
33+
},
34+
{
35+
"caption": "Directive",
36+
"command": "angularv2_cli",
37+
"args": {
38+
"command": ["generate", "directive", ":name_and_options"]
39+
}
40+
},
41+
{
42+
"caption": "Enum",
43+
"command": "angularv2_cli",
44+
"args": {
45+
"command": ["generate", "enum", ":name_and_options"]
46+
}
47+
},
48+
{
49+
"caption": "Guard",
50+
"command": "angularv2_cli",
51+
"args": {
52+
"command": ["generate", "guard", ":name_and_options"]
53+
}
54+
},
55+
{
56+
"caption": "Interface",
57+
"command": "angularv2_cli",
58+
"args": {
59+
"command": ["generate", "interface", ":name_and_options"]
60+
}
61+
},
62+
{
63+
"caption": "Module",
64+
"command": "angularv2_cli",
65+
"args": {
66+
"command": ["generate", "module", ":name_and_options"]
67+
}
68+
},
69+
{
70+
"caption": "Pipe",
71+
"command": "angularv2_cli",
72+
"args": {
73+
"command": ["generate", "pipe", ":name_and_options"]
74+
}
75+
},
76+
{
77+
"caption": "Service",
78+
"command": "angularv2_cli",
79+
"args": {
80+
"command": ["generate", "service", ":name_and_options"]
81+
}
82+
}
83+
]
84+
},
1785
{
1886
"caption": "Lint",
1987
"command": "angularv2_cli",

project/angularv2/default_config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"serve_options": [],
55
"lint_options": [],
66
"test_options": [],
7-
"e2e_options": [],
8-
"build_options": {
7+
"e2e_options": [],
8+
"build_options": {
99
"dev": [],
1010
"prod": []
1111
},
12-
"eject_options": [],
13-
"xi18n_options": []
12+
"eject_options": [],
13+
"xi18n_options": []
1414
}

project/angularv2/main.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,33 @@ class angularv2_cliCommand(manage_cliCommand):
6262

6363
def prepare_command(self, **kwargs):
6464

65-
# if self.command[0] in ["angular:controller", "angular:directive", "angular:filter", "angular:route", "angular:service", "angular:provider", "angular:factory", "angular:value", "angular:constant", "angular:decorator", "angular:view"]:
66-
# sublime.active_window().show_input_panel( (self.command[0].replace("angular:", ""))+" name:", "", self.name_on_done, None, None )
67-
# else :
68-
# self._run()
65+
if ":name_and_options" in self.command:
66+
sublime.active_window().show_input_panel( self.command[0] + " " + self.command[1] + " name and options:", "", self.name_and_options_on_done, None, None )
67+
else :
68+
self._run()
6969

70-
self._run()
71-
72-
def name_on_done(self, name):
73-
self.placeholders[":name"] = shlex.quote(name)
70+
def name_and_options_on_done(self, name_and_options):
71+
self.placeholders[":name_and_options"] = name_and_options.strip()
7472
self.command = self.substitute_placeholders(self.command)
7573
self._run()
7674

7775
def _run(self):
78-
# try:
79-
# self.command = {
80-
# 'serve': lambda : self.command + self.settings["angularv2_settings"]
81-
# }[self.command[0]]()
82-
# except KeyError as err:
83-
# pass
84-
# except Exception as err:
85-
# print(traceback.format_exc())
86-
# pass
8776

77+
try:
78+
self.command = {
79+
'build': lambda : self.command + self.settings["angularv2_settings"]["platform_run_options"][self.command[2].replace('--', '')],
80+
'serve': lambda : self.command + self.settings["angularv2_settings"]["serve_options"],
81+
'lint': lambda : self.command + self.settings["angularv2_settings"]["lint_options"],
82+
'test': lambda : self.command + self.settings["angularv2_settings"]["test_options"],
83+
'e2e': lambda : self.command + self.settings["angularv2_settings"]["e2e_options"],
84+
'eject': lambda : self.command + self.settings["angularv2_settings"]["eject_options"],
85+
'xi18n': lambda : self.command + self.settings["angularv2_settings"]["xi18n_options"]
86+
}[self.command[0]]()
87+
except KeyError as err:
88+
pass
89+
except Exception as err:
90+
print(traceback.format_exc())
91+
pass
92+
8893
super(angularv2_cliCommand, self)._run()
8994

project/cordova/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def prepare_command(self, **kwargs):
7373
self._run()
7474

7575
def platform_on_done(self, platform):
76-
self.placeholders[":platform"] = shlex.quote(platform)
76+
self.placeholders[":platform"] = shlex.quote(platform.strip())
7777
self.command = self.substitute_placeholders(self.command)
7878
self._run()
7979

project/ionicv1/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def prepare_command(self, **kwargs):
7272
self._run()
7373

7474
def platform_on_done(self, platform):
75-
self.placeholders[":platform"] = shlex.quote(platform)
75+
self.placeholders[":platform"] = shlex.quote(platform.strip())
7676
self.command = self.substitute_placeholders(self.command)
7777
self._run()
7878

project/ionicv2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def prepare_command(self, **kwargs):
7373
self._run()
7474

7575
def platform_on_done(self, platform):
76-
self.placeholders[":platform"] = shlex.quote(platform)
76+
self.placeholders[":platform"] = shlex.quote(platform.strip())
7777
self.command = self.substitute_placeholders(self.command)
7878
self._run()
7979

0 commit comments

Comments
 (0)