巨蟒到壳牌脚本编译器
sherlock.p的Python项目详细描述
sherlock.py是将python转换为shell脚本语言的transpiler。
Motivation
<;使用shell脚本的活动who程序>;
shell脚本是一种众所周知的脚本语言,在大多数类unix操作系统中都有使用。shell脚本lanuage garunte在大多数类unix操作系统中运行。很多软件开发人员在编写安装脚本或配置脚本时都使用这种语言。因为这种语言很古老,所以有几个problems。用shell脚本语言编写的程序很难维护。
Usage
usage: sherlock [-h] [-o output] [-c] [-v] [--version] [file | command] Python to bash trans-compiler. positional arguments: [file | command] program read from script file optional arguments: -h, --help show this help message and exit -o output output file path -c, --command program passed in as string -v, --verbose program run in verbose mode --version show program's version number and exit
以下是基本用法。
$ sherlock target.py
使用此命令,target.py文件将转换为shell sciprt。之后,它将使用sh自动运行。我们可以从运行结果中找出bug。
$ sherlock target.py -o output.sh
使用-o标志,可以将sherlock结果保存到文件中。在这种情况下,脚本不会自动运行。
$ sherlock -c "echo 'Hello World.'"
使用-c标志,输入命令立即转换为shell脚本语言并执行。
如果你想详细说明的话。请检查sample codes
Library
sherlock.cmd包
可以使用从sherlock.cmd导入的常规shell命令。导入包时,它会检查用户已安装的命令并创建返回stdout输出的wrap函数。
fromsherlock.cmdimportlsls('-al')
管道函数
在shell脚本中,可以将命令与|运算符组合。为了在python中做同样的事情,sherlock.py支持管道函数。
fromsherlock.cmdimportwcpipe(print('./test'),wc('-c'))
Todo
- 导入语法
- command包
- 文档
- 支持Windows批处理和powershell脚本
- 更多测试…