How to use the args.Parser function in args

To help you get started, we’ve selected a few args examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kriskowal / narwhal-lib / lib / narwhal / tusk / commands / install.js View on Github external
// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
// -- tlrobinson Tom Robinson

var tusk = require("../../tusk");
var util = require("util");
var args = require("args");
var fs = require("file");
var json = require("json");
var http = require("http");
var zip = require("zip");
var packages = require("packages");

var parser = exports.parser = new args.Parser();

parser.help('downloads and installs a package and its dependencies');

parser.args('package');

parser.option('-f', '--force', 'force')
    .bool()
    .help('causes packages to be installed in the project packages directory regardless of whether they are installed elsewhere');
/*
parser.option('-l', '--lean', 'lean')
    .bool()
    .help('causes only the essential components of the library to be installed.');

parser.option('-t', '--test', 'test')
    .bool()
    .help('run tests before installing');
github kriskowal / narwhal-lib / lib / narwhal / tusk / commands / update.js View on Github external
// Kris Kowal

var UPDATE = require("../update");
var ARGS = require("args");
var FS = require("file");

var parser = exports.parser = new ARGS.Parser();

parser.args("PACKAGE");

parser.help('downloads the newest package catalog');

parser.option('-c', '--use-cache')
    .help("configures to use already downloaded files when possible")
    .set(true);

parser.option('-i', '--input')
    .help("specifies an alternate location to read the input catalog sources")
    .set();

parser.option('-o', '--output')
    .help("specifies an alternate location to write the output catalog")
    .set();
github Gozala / jsdocs / lib / jsdocs / dep.jsdocs.js View on Github external
Log.trace = function(object) { print(require("test/jsdump").jsDump.parse(object)) }

// Default values
var defaults = {
    templatePath: "templates/dark-pastels",
    destinationPath: "docs",
    includeUndocumented: true,
    includePrivates: true,
    encoding: "utf-8",
    nocode: false,
    depth: 0,
    verbose: false,
    fileExtensions: [".js"]
};

var parser = new (require("args").Parser)();

parser.usage("jsdocs [options] [file / directory containing source");
parser.help("Generates documentation from the javascript source and jsdoc comments.");

parser.option("-t", "--template", "template")
    .help("Relative path to the template used for formating the output.")
    .def(require('packages').catalog['jsdocs'].directory.join("templates", "dark-pastels"))
    .set();

parser.option("-a", "--all", "includeUndocumented")
    .help("Include all functions, even undocumented ones.")
    .set(true);

parser.option("-d", "--destination", "destination")
    .help("Relative path to the output directory")
    .def("docs")
github kriskowal / narwhal-lib / lib / narwhal / tusk / commands / install.js View on Github external
// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
// -- tlrobinson Tom Robinson

var tusk = require("../../tusk");
var util = require("util");
var args = require("args");
var fs = require("file");
var json = require("json");
var http = require("http-client");
var zip = require("zip");
var packages = require("packages");
var URI = require("uri");
var UUID = require("uuid");

var parser = exports.parser = new args.Parser();

parser.help('downloads and installs a package and its dependencies');

parser.args('package');

parser.option('-f', '--force', 'force')
    .bool()
    .help('causes packages to be installed in the project packages directory regardless of whether they are installed elsewhere');
/*
parser.option('-l', '--lean', 'lean')
    .bool()
    .help('causes only the essential components of the library to be installed.');

parser.option('-t', '--test', 'test')
    .bool()
    .help('run tests before installing');
github kriskowal / narwhal-lib / lib / narwhal / tusk / engine.js View on Github external
var os = require('os');
var util = require('util');
var tusk = require('../tusk');
var args = require('args');

var parser = exports.parser = new args.Parser();

parser.help('selects a engine for the current "sea"');

parser.arg('engine').optional();

parser.action(function (options) {
    var self = this;
    var directory = tusk.getDirectory();
    var enginesDirectory = directory.join('engines');
    if (options.args.length == 0) {
        enginesDirectory.list().forEach(function (engineName) {
            self.print(engineName);
        });
    } else {
        var engine = options.args.shift();
        if (!util.has(enginesDirectory.list(), engine))
github kriskowal / narwhal-lib / lib / narwhal / tusk / clone.js View on Github external
var tusk = require("../tusk");
var os = require("os");
var util = require("util");
var args = require("args");

var parser = exports.parser = new args.Parser();

parser.help('clones a package from its version control system')

parser.args('package');

parser.option('-o', '--owner', 'owner')
    .help("clone from the owner's repository")
    .bool()
    .inverse();

parser.option('-u', '--user', 'user')
    .help('overrides the user name from which to clone the package')
    .set();

parser.action(function (options) {
    var self = this;
github veged / shmakowiki / lib / shmakowiki / 2html.js View on Github external
var file = require('file'),
    parser = exports.parser = new (require('args').Parser)();

parser.option('-i', '--input', 'input')
    .help('specifies filename to read the input source, if omit use STDIN')
    .def(system.stdin)
    .input();

parser.option('-o', '--output', 'output')
    .help('specifies filename to write the output, if omit use STDOUT')
    .def(system.stdout)
    .output();

parser.helpful();

exports.main = function () {
    var options = parser.parse(system.args),
        input = options.input.read();
github kriskowal / narwhal-lib / lib / narwhal / tusk / catalog.js View on Github external
var tusk = require("../tusk");
var util = require("util");
var args = require("args");

var parser = exports.parser = new args.Parser();

parser.help('lists all packages in the catalog');

parser.action(function (options) {
    var self = this;
    if (!tusk.getCatalogPath().isFile())
        require('./update').update.call(this, options);
    util.forEachApply(tusk.readCatalog().packages, function (name, info) {
        name = info.name || name;
        self.print(
            "\0green(" + name + "\0)" + 
            (info.description ? ": " + info.description : "")
        );
    });
});
github kriskowal / narwhal-lib / lib / narwhal / tusk / reheat.js View on Github external
var tusk = require("../tusk");
var install = require('./install');
var util = require("util");
var args = require("args");
var packages = require('packages');
var parser = exports.parser = new args.Parser();

parser.help('reconsistutes the exact versions of all dependencies from a frozen project');

parser.action(function (options, name) {
    var names = packages.root.dependencies || [];
    install.install.call(this, options, names);
});
github kriskowal / narwhal-lib / lib / narwhal / tusk / commands / create-catalog.js View on Github external
var tusk = require("../../tusk");
var util = require("util");
var args = require("args");
var http = require("http");
var json = require("json");

var parser = exports.parser = new args.Parser();

parser.help('creates a catalog of packages from sources.json');

parser.action(function (options) {
    var self = this;
    var sources = tusk.readSources();
    var catalog = {};
    catalog['!'] = "This file is generated by 'tusk create-catalog', copied from '.tusk', and committed only so that it may be downloaded from Github with 'tusk update'.";
    catalog.version = util.copy(sources.version);
    var packages = catalog.packages = {};
    util.forEachApply(
        util.items(sources.packages || {}),
        function (name, source) {
            var info;

            if (source['package.json'])