aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nomnom/test/option.js
blob: e3934d75eb6f267a0589bc920f4081c3e2dc4655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var nomnom = require("../nomnom");

var parser = nomnom()
   .option('debug', {
      abbr: 'x',
      flag: true,
      help: 'Print debugging info'
   })
   .option('config', {
      abbr: 'c',
      default: 'config.json',
      help: 'JSON file with tests to run'
   })
   .option('version', {
      flag: true,
      help: 'print version and exit',
      callback: function() {
         return "version 1.2.4";
      }
   });


exports.testOption = function(test) {
   var opts = parser.parse(["-x", "--no-verbose"]);

   test.strictEqual(opts.debug, true);
   test.equal(opts.config, "config.json");
   test.done();
}


exports.testCommandOption = function(test) {
   var parser = nomnom()
   parser.command('test')
     .option('fruit', {
        abbr: 'f',
        flag: true
     })

   var opts = parser.parse(["test", "-f"]);

   test.strictEqual(opts.fruit, true);
   test.done();
}