Created
June 3, 2017 06:48
-
-
Save g8up/653f11d879bb08fb985382174c2d9d36 to your computer and use it in GitHub Desktop.
FIS 工程周边 SublimeText3 插件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 配合描述文件 Context.sublime-menu,内容如下 | |
# [{ | |
# "caption": "Cmd", | |
# "command": "cmd" | |
# }] | |
import os, sublime_plugin, sublime | |
class CmdCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
file_name=self.view.file_name() | |
path=file_name.split("\\") | |
current_driver=path[0] | |
path.pop() | |
current_directory="\\".join(path) | |
command= "cd "+current_directory+" & "+current_driver+" & start cmd" | |
os.system(command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @file duxing.py | |
# @desc 置于 Preferences -> Browser Packages 弹出的目录下 | |
import os, sublime | |
# 解析命令行 | |
def runCommand( cd, commands ): | |
if( len( commands ) > 0 ): | |
if( cd != "" ): | |
os.chdir( cd ) | |
commands.reverse() | |
commandStr = " & ".join( commands ) | |
print( "执行命令", commandStr ) | |
os.system( commandStr ) | |
else: | |
sublime.message_dialog( "命令不能为空" ) | |
# 解析路径到 fis 工程根目录:根据目录中是否有`widget`文件夹判断 | |
def getFisProjectPath( paths ): | |
while( len (paths) > 0 and not os.path.exists( "\\".join( paths ) + "\\widget" ) ): | |
curPath = paths.pop() | |
# sublime.message_dialog( str( len (paths)) ) | |
if( len (paths) == 0 ): | |
return "" | |
return "\\".join(paths) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SublimeText3 Plugin Doc:http://www.sublimetext.com/docs/3/api_reference.html | |
# python doc: http://www.runoob.com/python/python-tutorial.html | |
# 给右键菜单提供一个命令,点击弹出 cmd 并切换目录到 fis 工程根目录 | |
# 配合描述文件 Context.sublime-menu,内容如下 | |
# [{ | |
# "caption": "FisProjectRoot", | |
# "command": "go_to_fis_project_root" | |
# }] | |
import os, sublime_plugin, sublime, duxing | |
class GoToFisProjectRootCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
file_name = self.view.file_name() | |
# sublime.message_dialog( file_name ) # debug | |
path = file_name.split("\\") | |
current_directory = duxing.getFisProjectPath( path ) | |
commands = [ | |
"start cmd" | |
] | |
duxing.runCommand( current_directory, commands) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment