问题描述
我目前正在制作一个在终端上运行的程序(需要一些参数).
I'm currently making a program (which requires some arguments) that runs on the terminal.
现在我想从 Sublime Text 运行这个相同的程序,但我不知道如何在 Sublime Text 中执行程序之前将参数传递给构建.
Now I would like to run this same program from Sublime Text, but I don't know how to pass parameters to the build before executing the program in Sublime Text.
是否需要启用任何选项来指定参数?
Is there any option that I need to enable to specify the arguments?
使用 Sublime Text 3 build 3035
Using Sublime Text 3 build 3035
推荐答案
您可以为 sublime text 创建一个新的构建系统,并使用固定参数运行您的脚本.
You can create a new build system for sublime text and run your script with fixed arguments.
在您的包/用户目录中创建一个新文件 (CTRL-SHIFT-P -->浏览包"
)
Create a new File in your Packages/User directory (CTRL-SHIFT-P --> "Browse Packages"
)
新文件:Packages/User/my_build.sublime-build
具有以下内容:
{
"cmd": ["python", "$file", "arg1", "arg2"]
}
(用您的参数替换 arg1,arg2 - 如果需要,您可以删除它们或添加更多)
(replace arg1,arg2 by your arguments - you can delete them or add more if you want)
现在重新启动 sublime text 并在菜单中选择您的构建系统:Tools -->构建系统 -->my_build
.从现在开始,当您按下 CTRL-B 时,您的构建系统将被执行.
Now restart sublime text and select your build system in the Menu: Tools --> Build System --> my_build
. From now on, when you press CTRL-B your build system will be executed.
不要忘记将其改回自动";如果您正在处理其他文件或项目.
Don't forget to change it back to "Automatic" if you are working on other files or projects.
您可以在构建文件中设置许多选项.请参考 https://docs.sublimetext.io/guide/usage/build-systems.html
There are many options you can set in build files. Please refer to https://docs.sublimetext.io/guide/usage/build-systems.html
这篇关于如何将参数传递给 Sublime Text 3 中的构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!