Giter VIP home page Giter VIP logo

commands-run's Introduction

Overview

It's simple tool to run many command lines in one command line

Installation

Run command line :

npm i

Use

  • Copy commands.template.json in the same directory and rename it commands.json. Replace content with your commands list.
  • Run command line :
npm start [group command name]

Example

  • Create a simple file count.js in the same directory
const args = process.argv.slice(2);

/**
 * First argument will be used as total count
 */
const total = args[0];

/**
 * Second argument will be used as sleep time
 */
const sleep = args[1];

let index = 0;

function count() {
    index++;
    
    console.log(`Count ${index}`);
    if (index >= total)
        return;

    setTimeout(count, sleep);
}

/**
 * Count from 1 to total in sleep interval time
 */
count();
  • Create commands.json in the same directory
{
    "rapidCount": [
        {
            "command": "node count 10 500",
            "name": "First count"
        },
        {
            "command": "node test 10 300",
            "name": "Second count"
        }
    ],
    "slowCount" : [
        {
            "command": "node count 5 5000",
            "name": "First count",
            "timeout" : 1000
        },
        {
            "command": "node count 5 3000",
            "name": "Second count"
        },
        {
            "command": "node count 3 7000",
            "name": "Third count"
        }
    ]
}
  • Let's run the slow count :D
npm start slowCount

It will output something like :

[DEBUG First count] > Run command [node count 5 5000] at [your directory]
[DEBUG First count] : Count 1
[DEBUG First count] > Timeout [1000 ms] reached
[DEBUG Second count] > Run command [node count 5 3000] at [your directory]
[DEBUG Second count] : Count 1
[DEBUG First count] : Count 2
[DEBUG Second count] : Count 2
[DEBUG Second count] : Count 3
[DEBUG First count] : Count 3
[DEBUG Second count] : Count 4
[DEBUG Second count] : Count 5
[DEBUG Second count] > Command closed with code [0]
[DEBUG Third count] > Run command [node count 3 7000] at [your directory]
[DEBUG Third count] : Count 1
[DEBUG First count] : Count 4
[DEBUG First count] : Count 5
[DEBUG First count] > Command closed with code [0]
[DEBUG Third count] : Count 2
[DEBUG Third count] : Count 3
[DEBUG Third count] > Command closed with code [0]

commands-run's People

Contributors

razafinarivohanania avatar

Watchers

 avatar

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.