🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

matchcmd

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matchcmd

Parser for routing strings to commands.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Installation

npm install matchcmd

What does it do?

matchcmd is a parser for routing strings to commands. Commands can be statically typed or used with STDIN for a script. Each command assumes all arguments are matched to any character other than spaces, tabs, or empty characters.

Example

    var cmd = require('./matchcmd.js');

    cmd.use('resize :width :height?', function(command){
        console.log('Resize to %spx WIDTH %spx HEIGHT', command.args.width, command.args.height || command.args.width);
    });

    cmd.use(['rs', 'restart'], function(command){
        console.log('Restarted?');
    });
    cmd.fail(function(input){
        return console.log('Command failed! Command: %s', input);
    });

    cmd.send('resize 200 500');
    cmd.send('RESIZE 100');
    cmd.send('rs');
    cmd.send('restart');
    cmd.send('fake command');

Results:

    Resize to 200px WIDTH 500px HEIGHT
    Resize to 100px WIDTH 100px HEIGHT
    Restarted?
    Restarted?
    Command failed! Command: fake command

Keywords

command

FAQs

Package last updated on 19 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts