How to use optimist

Comprehensive optimist code examples:

How to use optimist.r:

44
45
46
47
48
49
50
51
52
53
// PERFORM RELEASE //
/////////////////////

var packageJsonPath = path.resolve('package.json');
var packageDest = 'dist';
var remoteName = argv.r;
var version = argv.v;

// Ensure everything is OK to do a release
ReleaseUtil.validateRelease(remoteName, 3);

How to use optimist.help:

48
49
50
51
52
53
54
55
56
57
    '  lmd server ' + 'development'.blue,
    '  lmd server ' + 'development'.blue + ' --a localhost --p 8080'.yellow,
    ''
];

var options = optimist.help().split('\n');
options.unshift(options[0].bold.white.underline);
options[1] = '';

help = help.concat(options);

How to use optimist.describe:

134
135
136
137
138
139
140
141
142
143
	optimist = optimist.default('f', path.join('config', 'windows.json'));
} else {
	optimist = optimist.default('f', path.join('config', 'sabi.json'));
}
// optimist = optimist.default('p', 'sage2');
optimist = optimist.describe('f', 'Load a configuration file');
optimist = optimist.describe('p', 'Create a password for the sage2 user');
var argv = optimist.argv;
if (argv.h) {
	optimist.showHelp();

How to use optimist.port:

40
41
42
43
44
45
46
47
48
49
}

var http = require('http');
// set and check the validity of the HTTP listen port
// the environment variable $PORT is read for deployment on heroku
var httpport = process.env.PORT || argv.port;
if (isNaN(httpport) || httpport < 1) {
    console.log("missing or incorrect http listen port: '" + httpport + "' using default 8888\n");
    httpport = 8888;
}

How to use optimist.ssl:

67
68
69
70
71
72
73
74
75
76
77
78
    sshuser = opts.sshuser;
}


if (opts.sslkey && opts.sslcert) {
    opts.ssl = {};
    opts.ssl.key = fs.readFileSync(path.resolve(opts.sslkey));
    opts.ssl.cert = fs.readFileSync(path.resolve(opts.sslcert));
}



How to use optimist.L:

57
58
59
60
61
62
63
64
65
66

tryClang(function (ret) {
  var library;

  if (isNaN(ret)) library = ret;
  if (argv.L) library = argv.L;

  if (ret === true) {
    generate();
  } else if (library && ret !== false) {

How to use optimist.options:

72
73
74
75
76
77
78
79
80
81
    return true;
}

module.exports = function (cli, argv, cwd) {
    for (var optionName in options) {
        optimist.options(optionName, options[optionName]);
    }
    argv = optimist.parse(argv);

    var status,

How to use optimist.default:

129
130
131
132
133
134
135
136
137
138
139
// ---------------------------------------------


console.log('--------------------------------------------');
optimist = optimist.usage('Usage: $0 -h -p password -f [json file]');
if (platform === "Windows") {
	optimist = optimist.default('f', path.join('config', 'windows.json'));
} else {
	optimist = optimist.default('f', path.join('config', 'sabi.json'));
}
// optimist = optimist.default('p', 'sage2');

How to use optimist.parse:

74
75
76
77
78
79
80
81
82

module.exports = function (cli, argv, cwd) {
    for (var optionName in options) {
        optimist.options(optionName, options[optionName]);
    }
    argv = optimist.parse(argv);

    var status,
        buildName = argv._[1];

How to use optimist.title:

12
13
14
15
16
17
18
19
20
21
// Textus configuration
var conf = require('../js/textusConfiguration.js').conf();
// Backend datastore, requires configuration
var ds = require('../js/datastore/dataStore-elastic.js')(conf);

var title = args.title;

var createDummyAnnotations = function(string, count, spanlength) {
        annotations = [];
        for ( var i = 0; i < count; i++) {

How to use optimist.folder:

7
8
9
10
11
12
13
  .alias('f', 'folder')
  .argv;

ebook({
  source: argv.source,
  folder: argv.folder
});

How to use optimist.v:

45
46
47
48
49
50
51
52
53
/////////////////////

var packageJsonPath = path.resolve('package.json');
var packageDest = 'dist';
var remoteName = argv.r;
var version = argv.v;

// Ensure everything is OK to do a release
ReleaseUtil.validateRelease(remoteName, 3);

How to use optimist.language:

21
22
23
24
25
26
27
28
29
30
31
32
argv.input = fs.realpathSync(argv.input);


var options = {
	path: argv.input,
	output: argv.output || argv.input,
	language: argv.language.toLowerCase(),
	convention: argv.convention.toLowerCase(),
};


var languageDefintion = null;

How to use optimist.convention:

22
23
24
25
26
27
28
29
30
31
32
33


var options = {
	path: argv.input,
	output: argv.output || argv.input,
	language: argv.language.toLowerCase(),
	convention: argv.convention.toLowerCase(),
};


var languageDefintion = null;
var tokenPatterns = [];

How to use optimist._:

84
85
86
87
88
89
90
91
92
});


var maxat = subs.reduce(function(acc, el) { return acc > el.end ? acc : el.end; }, 0);

var specs = argv._.map(parseSpec);

specs.unshift({at: -1, shift: specs[0].shift});
specs.push({at: maxat + 1, shift: specs[specs.length - 1].shift});

How to use optimist.usage:

37
38
39
40
41
42
43
44
45
46
              + '\nIf no arguments are specified, uCSS will assume there is a '
              + 'config_ucss.js file in the current directory.');
};

// Arguments parsing
var argv = optimist.usage('Check if CSS selectors matches anything in given HTML.\n'
                          + 'Usage: $0 [OPTION]...')
    .options({
      help: {
        description: 'This help text.'

How to use optimist.sshuser:

55
56
57
58
59
60
61
62
63
64
65
66
if (opts.sshauth) {
	sshauth = opts.sshauth
}


if (opts.sshuser) {
    globalsshuser = opts.sshuser;
}


if (opts.sslkey && opts.sslcert) {
    runhttps = true;

How to use optimist.sshport:

43
44
45
46
47
48
49
50
51
52
53
54
var sshhost = 'localhost';
var sshauth = 'password,keyboard-interactive';
var globalsshuser = '';


if (opts.sshport) {
    sshport = opts.sshport;
}


if (opts.sshhost) {
    sshhost = opts.sshhost;

How to use optimist.sshhost:

47
48
49
50
51
52
53
54
55
56
57
58
if (opts.sshport) {
    sshport = opts.sshport;
}


if (opts.sshhost) {
    sshhost = opts.sshhost;
}


if (opts.sshauth) {
	sshauth = opts.sshauth

How to use optimist.sshauth:

51
52
53
54
55
56
57
58
59
60
61
62
if (opts.sshhost) {
    sshhost = opts.sshhost;
}


if (opts.sshauth) {
	sshauth = opts.sshauth
}


if (opts.sshuser) {
    globalsshuser = opts.sshuser;

How to use optimist.showHelp:

38
39
40
41
42
43
44
45
46
47

  .describe('help', 'Print usage instructions')
  .alias('h', 'help')
  .argv

if (argv.help || !argv.sites) return optimist.showHelp()

var server = review()

server.title(argv.title)

How to use optimist.argv:

21
22
23
24
25
26
27
28
29
30
    .alias('?', 'help')
    .describe('?', 'Print usage information');

// get credentials either from command line or config.json in ~/.teslams/config.js
var creds = require('./config.js').config(argv);
argv = argv.argv;

if (argv.help === true) {
    console.log('Usage: teslacmd.js -u <username> -p <password> -XZ');
    console.log('                   -P [listen port (default 8888)]');