Giter VIP home page Giter VIP logo

easterapps / vscode-script-runner Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 0.0 251 KB

Run command line scripts (with parameters) directly from #VSCode with a configured form.

Home Page: https://marketplace.visualstudio.com/items?itemName=easterapps.script-runner

License: MIT License

TypeScript 100.00%
vscode-extension vscode typescript script-runner command-palette keyboard-shortcut extension nodejs

vscode-script-runner's Introduction

cmd exec for VS Code

version version

What is cmd exec

Run command line scripts (with parameters) directly from #VSCode with a configured form. Create and customize your own commands to simplify your way of working.

Follow the instructions How to setup cmd exec to use this extension.

How to setup cmd exec

  1. Use ctrl+shift+P or F1 to invoke the Command Palette
  2. Type Preferences: Open Settings (JSON)
  3. Add/copy basic configuration to settings.json
  "script-runner.statusBar" : false,
  "script-runner.definitions": {
    "commands": [


    ],
    "variables": {

    }
  }
  1. Add command definitions to commands

Sample command definition:

{
  "identifier": "test",
  "description": "Test Runner",
  "command": "echo $var1 $var2",
  "working_directory": "./",
  "form": [
    {
      "variable": "$var1",
      "question": "What is $var1?",
      "default": "Test 1"
    },
    {
      "variable": "$var2",
      "question": "What is $var2?",
      "options": ["Option 1", "Option 2", "Option 3"]
    }
  ]
}
  1. Define variables for all command definitions in variables
"variables": {
  "$tmp": "./"
}
Name Description Required Type
identifier Identifier used to do key binding. Use alphanumerical and hyphen/underscore only. yes string
description Description of the command. yes string
command Command to execute (with variables). yes string
working_directory The working directory in which to execute the script. string
form A list of questions to ask in order to obtain values for variables. array
variable The variable name. string
question The question to ask the user. string
password Input is a password. Default is false. Suggestion: use also show_in_console: false boolean
default The default value to put in the field. Only for text inputs. string
defaultValuePath Overrides the default value with the current file path. Empty if no file open. password option ignored boolean
defaultValueFilename Overrides the default value with the current filename. Empty if no file open. password option ignored boolean
options List of options (string) array
variables List of variables (string) array

Full Configuration Sample

"script-runner.statusBar": true,
"script-runner.definitions": {
    "commands": [
      {
        "identifier": "test",
        "description": "Test Runner 1",
        "command": "echo $var1 $var2",
        "working_directory": "$tmp",
        "form": [
          {
            "variable": "$var1",
            "question": "What is $var1?",
            "default": "Test 1"
          },
          {
            "variable": "$var2",
            "question": "What is $var2?",
            "options": [
              "Option 1",
              "Option 2",
              "Option 3"
            ]
          }
        ]
      },
      {
        "identifier": "test2",
        "description": "Test Runner 2",
        "command": "echo $var1 ",
        "working_directory": "$tmp",
        "form": [
          {
            "variable": "$var1",
            "question": "What is $var1?",
            "default": "Test 1"
          }
        ]
      },
      {
        "identifier": "filepath1",
        "description": "Filepath",
        "command": "echo $path ",
        "working_directory": "$tmp",
        "form": [
          {
            "variable": "$path",
            "question": "What is the path",
            "defaultValuePath": true
          }
        ]
      }
    ],
    "variables": {
      "$tmp": "./"
    }
  }

Usage

Use your defined Commands from Command Palette

  1. Use ctrl+shift+P or F1 to invoke the Command Palette.
  2. Type Script Runner: Run.
  3. Your list of commands will appear, you can then select the one to execute.
  4. If your command has a form, the questions will be displayed.
  5. The command will be executed.

Use your defined Commands from Status Bar

If you enable the statusbar item, it will be placed at the right corner of the bottom status bar.

"script-runner.statusBar" : true,

Use keyboard shortcut for specific defined commands

You can bind a keyboard shortcut to the command. Keyboard Shortcuts script-runner.$command_identifier$.

Use a different shell

"script-runner.customShell.enabled": true,
"script-runner.customShell.path": "/bin/sh",

Contributing

File bugs, feature requests in Github Issues.

Leave a review on Visual Studio Marketplace.

vscode-script-runner's People

Contributors

dependabot[bot] avatar easterapps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-script-runner's Issues

per-folder scripts

I have been experimenting with Script Runner and it seems really useful. Putting script definitions in the main settings.json file, as per the readme, works fine, and it is also possible to add them to a .code-workspace file, which lets me define different scripts for each workspace.

One thing that doesn't seem to work though is adding a script definition to a folder/.vscode/settings.json file. This would be really useful as I could then create scripts for use within that specific project (I put different projects into folders in one workspace). Am I doing something wrong, or if not then could this feature be added?

Thanks!

[Feature request] Group commands

Please add ability to group commands. Add one more variable into settings, say group:

"group": "Angular"

after calling your extension you should see:

image

and after clicking on Angular you should see only commands that are grouped ander Angular:

image

[Feature request] Contex menu commands

Please add ability of running commands through context menu:

image

Then, in dropdown menu, should be visible only those commands that have property:

"ContextMenuCommand": true

also within settings should be acceceble built in property Current/ClickedFilePath and CurrentFolderPath. Say if I click on folder temp or temp/index.html the value of the CurrentFolderPath should be temp folder's path. Then I will use it into commands. If you click on temp/index.html the value of Current/ClickedFilePath should be index.html file's path.

[Feature request] Form options object

At this moment we use array as an option:

image

Please add ability to use an object also. It is useful when you want to use not only a simple value but terminal commands:

image

or something like this:

sppp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.