Example #1
0
            cli.output(line + sep);
        } else if (cli.args.length) {
            output_file(cli.args.shift());
        }
    });
};

if (cli.args.length) {
    output_file(cli.args.shift());
}

// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/command.js
// ============================================================================

cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);

console.log('Command is: ' + cli.command);


// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/echo.js
// ============================================================================

cli.parse({
    newline:   ['n', 'Do not output the trailing newline'],
    escape:    ['e', 'Enable interpretation of backslash escapes'],
    separator: ['s', 'Separate arguments using this value', 'string', ' '],
    output:    [false, 'Write to FILE rather than the console', 'file']
});
Example #2
0
    build,
} from './main';

import * as log from './log';

cli.enable('version');

const pkg = require(path.join(pkgDir.sync(__dirname), 'package.json'));

cli.parse({
    project: ['p', 'Project file', 'path'],
    outDir: ['o', 'Output directory', 'path'],
    force: ['f', 'Force all files to be re-rendered'],
    nobuild: [null, 'Disable startup building.'],
    watch: ['w', 'Watch'],
    server: ['s', 'Enable web server for testing.'],
    port: [null, 'Port number of web server.', 'number'],

    // logs
    quiet: ['q', 'Quiet logs'],
    verbose: [null, 'Verbose logs'],
});

cli.main((args, options)=>{
    if (options.quiet){
        log.setLogLevel(log.LogLevel.error);
    }
    if (options.verbose){
        log.setLogLevel(log.LogLevel.verbose);
    }
Example #3
0
import build_drives = require('./build-drives');
import path = require('path');
import fs = require('fs');
var cli = require('cli');
var log = require('./log');


var commands = [
    'layer',
    'bundle',
    'server'
];

cli.parse({
    file:               ['f',       'portable.js config file location',         'string'],
    verbose:            ['v',       'Aggressively print logs to console'],
    debug:              ['',        'Output debug info'],
}, commands);

cli.main(function(args, options) {
    try {
        if(cli.command) {
            if(commands.indexOf(cli.command) < 0) throw Error('Invalid command: ' + cli.command);

            // First try to run the `portable-js` package that is installed in folder where manifest file is located,
            // if not found, run the command from the global package.
            var manifest_dir = '';
            if(options.file) {
                manifest_dir = path.dirname(options.file);
            } else {
                manifest_dir = process.cwd();
Example #4
0
            new_argv.push(value);
        } else {
            new_argv.push(arg);
        }
    }
    process.argv = new_argv;
}

var cli = require('cli');


cli.parse({
    "config-file":  ['',            'Configuration file',                       "string"],
    config:         ['',            'Configuration as JSON string',             "string"],
    code:           ["c",           "Code to evaluate",                         "string"],
    port:           ["p",           "TCP port or UNIX socket file",             "string"],
    ssh:            ["",            "SSH host",                                 "string"],
    client:         ["",            "Connect to a jssh server",                 "bool"],
    stdio:          ["s",           "Communicate through STDIO",                "bool"],
});


cli.main(function(args, options) {
    //console.log(args, options);
    var file_arg_pos = 0; // Position of a file to include in arguments list.

    if(options['config-file']) {
        var path = require('path');
        var conffile = path.resolve(options['config-file']);
        try {
            var json = fs.readFileSync(conffile);