commands-runner
commands-runner is a cli tool to run commands that can be used to any thing
YOU MUST READ THIS IMPORT_NOTES
like creating a command to realise something or whatever
if you have issues, miss-understanding, questions or recommendation post an issue here
installation
via npm:
npm i -g commands-runner
NOTE: don't install this module with yarn
how to use
first create a file with you commandName followed
by .cmr.json
.cmr.json
files should follow the Commands
type bellow:
; ;
example 1:
making a command that do the following
- creating a git repo
- making some template
- running a file called
foo.js
"git init" // running git init template: "./template.zip" // extracting a file called template.zip script: "./print_hello_world.js" // running print_hello_world.js ;
NOTE: the file name should include the extension (.cmr.json)
- run
commands-runner add $fileName
- run
commands-runner start $fileName
and it will run the commands as needed
example 2: for providing a list for the user to choose what to do
ask: "choose something from the following" // the qeustion you want to ask multiple: true // if true make the user able to choose multiple options options: // the options title: "extract the template" // the title of the option template: "./template.zip" // to extract a template title: "run a file" script: "foo.js" // to run a js file title: "run some commands" commands: // to run some commands "echo hello world" script: "bar.js" // ... ;
example 3:
for using value
option
"ask": "what's the type of sandwich you want?" // the question "multiple": true // if you want to make the user able to use multiple options "options": // the options "title": "hot dog" // the title of the option "value": "hot dog" // the value of it "title": "cheese burger" "value": "cheese burger" "title": "chicken burger" "value": "cheese burger" "script": "./script.js" // the script you want to run after user choses options
when a user a select an option it will be passed in to the script as process arguments
if you use multiple it will be a JSON.stringify
ed array
for example:
// script.jsconsole; // will console log the value of option user selected
important-Notes
-
the script name of any of the commands should include the extension (.cmr.json)
-
when you use a script it get bundled so you probably won't be able to use any resources except json files (this might change in future versions)
-
any template or script name changes to a random hash
cli
you can use commands-runner
or cmr
to run this commands
start
start <script>
starts a script you already installed
add
add <script>
adds a script of commands for you to be able to use
delete
delete <script>
delete a script from the installed script
overwrite
overwrite <scriptToOverWrite> <script>
overwrite an installed script
config
config
a command to run the configuration file with VSCode
the config file should follow the type Config
below:
;
install-path
the path you want to install your script
the default is your home directory + "/commands-runner"
spinner-options
the spinner options
spinner
the spinner you want to choose for example: dots
or ``runner`
@default dots
color
the color of the spinner while it's running
it could be any valid chalk color
@default cyan
indent
indent the spinner with a given number of spaces
@default 0
indentBeforeOutput
indent the output of the command or script you're running with a given number of spaces
@default 3
succeedColor
the color of the spinner when it's done successfully
@default green
failColor
the color of the spinner when it fails
@default red
License
MIT License
Copyright (c) 2019 AliBasicCoder