热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

具有选项的Sublime文本构建系统-SublimeTextBuildSystemWithOptions

Ihavevariousshellbuildscriptsforaprojectandwanttocreateonecentralizedbuildsystemwit

I have various shell build scripts for a project and want to create one centralized build system with options that will allow which shell script to run. For example, a user presses Cmd + B then the user is given the option:

我有一个项目的各种shell构建脚本,并希望创建一个集中构建系统,其中包含允许运行哪个shell脚本的选项。例如,用户按下Cmd + B,然后为用户提供选项:

1) shellscript1.sh
2) shellscript2.sh
3) shellscript3.sh

1)shellscript1.sh 2)shellscript2.sh 3)shellscript3.sh

The user presses 3 and Sublime Text runs 'sh shellscript3.sh'.

用户按3,Sublime Text运行'sh shellscript3.sh'。

I've been reading http://sublimetext.info/docs/en/reference/build_systems.html, but am unsure how to integrate this option in the JSON code for the Sublime Text build system.

我一直在阅读http://sublimetext.info/docs/en/reference/build_systems.html,但我不确定如何在Sublime Text构建系统的JSON代码中集成此选项。

How do you accomplish this in a build system in Sublime Text 2?

你如何在Sublime Text 2的构建系统中实现这一目标?

Thanks!

3 个解决方案

#1


2  

Actually, you do not need your own plugin. All you need are build variants. Here's simple example using your example commands:

实际上,您不需要自己的插件。您只需要构建变体。以下是使用示例命令的简单示例:

{
  "name Script 1",
  "cmd": ["shellscript1.sh", "$file"],
  "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  "working_dir": "${project_path:${folder:${file_path}}}",

  "variants":
  [
    {
      "name": "Script 2",
      "cmd": ["shellscript2.sh", "$file"]
    },
    {
      "name": "Script 3",
      "cmd": ["shellscript3.sh", "$file"]
    }
  ]
}

Save this in your User preferences folder as MyScript.sublime-build. You will then be able to select it from the build menu, turning off the automatic target.

将其作为MyScript.sublime-build保存在用户首选项文件夹中。然后,您可以从构建菜单中选择它,关闭自动目标。

Now, when you press Command+B (on Mac, Control+B on Windows and Linux), the default target executes Script 1, on your file, but you can also select either of the variants.

现在,当您按下Command + B(在Mac上,在Windows和Linux上为Control + B)时,默认目标会在您的文件上执行脚本1,但您也可以选择其中一个变体。

See this answer, also, for a build file that I personally use providing variants for different Make targets.

对于我个人使用的构建文件,请参阅此答案,为不同的Make目标提供变体。

#2


1  

I don't know enough python to give you the specific code, but it looks like you need to write your own exec.py to handle an array of the commands and provide the control logic. Then in the JSON file, you would just need to write the value of the "cmd" key as [["first cmd"], ["second cmd"],..., ["last cmd"]],.

我不知道足够的python给你特定的代码,但看起来你需要编写自己的exec.py来处理命令数组并提供控制逻辑。然后在JSON文件中,您只需要将“cmd”键的值写为[[“first cmd”],[“second cmd”],...,[“last cmd”]] ,.

I'm following this question; I really like your idea.

我正在关注这个问题;我真的很喜欢你的主意。

#3


1  

I ended up making my own plugin and placed the following in run():

我最终制作了自己的插件并将以下内容放在run()中:

self.view.window().run_command('exec', {'cmd': ['sh', 'script.sh'], 'quiet': False})        

I based it off of the code of this Git Support plugin: https://github.com/notanumber/gitst2

我基于这个Git支持插件的代码:https://github.com/notanumber/gitst2


推荐阅读
  • 技术分享:从动态网站提取站点密钥的解决方案
    本文探讨了如何从动态网站中提取站点密钥,特别是针对验证码(reCAPTCHA)的处理方法。通过结合Selenium和requests库,提供了详细的代码示例和优化建议。 ... [详细]
  • 本文详细介绍了如何使用Python编写爬虫程序,从豆瓣电影Top250页面抓取电影信息。文章涵盖了从基础的网页请求到处理反爬虫机制,再到多页数据抓取的全过程,并提供了完整的代码示例。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 在使用 DataGridView 时,如果在当前单元格中输入内容但光标未移开,点击保存按钮后,输入的内容可能无法保存。只有当光标离开单元格后,才能成功保存数据。本文将探讨如何通过调用 DataGridView 的内置方法解决此问题。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • Sublime Text通过快捷键在浏览器中预览文件
    2019独角兽企业重金招聘Python工程师标准首先说下,我的是SublimeText3,win10。ST有个插件ViewInBrowser可以在 ... [详细]
  • 官网http:www.sublimetext.com插件https:packagecontrol.io教程SublimeText全程指南SublimeText2入门及技巧Subli ... [详细]
  • 前言--页数多了以后需要指定到某一页(只做了功能,样式没有细调)html ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • JavaScript中属性节点的类型及应用
    本文深入探讨了JavaScript中属性节点的不同类型及其在实际开发中的应用,帮助开发者更好地理解和处理HTML元素的属性。通过具体的案例和代码示例,我们将详细解析如何操作这些属性节点。 ... [详细]
  • 本文详细介绍了如何在 Windows 环境下使用 node-gyp 工具进行 Node.js 本地扩展的编译和配置,涵盖从环境搭建到代码实现的全过程。 ... [详细]
  • sublime php 方法,SublimePHPNinJaManual
    软件简介SublimePHPNinJaManual是Sublime中的函数手册提示,中文,其他语言的可以通过命令生成由来自己因为sublime中没有一个 ... [详细]
  • SublimeText2不能编译Python3.4.2Ctrl+B之后编译框没反应.Ctrl+`之后是这样: ... [详细]
  • 快速掌握Sublime Text3的使用方法,怎么汉化编辑器
    自动完成且反应快速的编辑器软件(关闭时是什么界面,打开时仍是什么界面,但需要手动保存文件,很经典)怎样将SublimeText3汉化:1、打开软件2、安装对应的插件即可,按ctrl ... [详细]
author-avatar
caiyafang4376
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有