Skip to content

Commit e896689

Browse files
committed
Add quick installation utility
1 parent ecc44a0 commit e896689

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

Main.sublime-menu

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,21 @@
122122

123123
},
124124
{
125-
"caption": "Grammar Installation",
125+
"caption": "Grammar Installation Doc",
126126
"command": "open_url",
127127
"args":{
128128
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/bundles/README.md"
129129
}
130+
},
131+
{
132+
"caption": "Quick 1.0.0 Installation",
133+
"command": "quick_install_python_voice_coding_plugin",
134+
"args":{}
130135
}
131136

132137

133138

139+
134140
]
135141
}
136142
]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
import sys
3+
4+
import sublime
5+
import sublime_plugin
6+
7+
8+
9+
10+
class QuickInstallPythonVoiceCodingPluginCommand(sublime_plugin.WindowCommand):
11+
def run(self):
12+
if sublime.platform()!="windows":
13+
sublime.error_message("Quick install has only meaning in windows")
14+
return
15+
candidates = []
16+
for user in os.listdir("C:\\Users"):
17+
for x in [".caster\\rules","AppData\\Local\\caster\\rules"]:
18+
if os.path.isdir(os.path.join("C:\\Users",user,x)):
19+
candidates.append(os.path.join("C:\\Users",user,x))
20+
if not candidates:
21+
return
22+
def on_done(index):
23+
if index==-1:
24+
return
25+
c = candidates[index]
26+
name = "python_voice_coding_plugin_caster_v1-0-0.py"
27+
if os.path.exists(os.path.join(c,name)):
28+
if sublime.yes_no_cancel_dialog("The grammar file already exists, surely you want to replace it")!=sublime.DIALOG_YES:
29+
return
30+
31+
with open(os.path.join(sublime.packages_path(),"PythonVoiceCodingPlugin\\bundles\\Caster",name),"r") as f:
32+
s = f.read()
33+
with open(os.path.join(c,name),"w") as f:
34+
f.write(s)
35+
36+
self.window.show_quick_panel(candidates,on_done)
37+
38+
39+
40+
41+
42+
43+
44+

0 commit comments

Comments
 (0)