coa 0.3.6 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +4 -1
- package/.travis.yml +11 -0
- package/GNUmakefile +22 -3
- package/README.md +6 -0
- package/index.js +1 -0
- package/lib/arg.js +18 -2
- package/lib/cmd.js +87 -18
- package/lib/color.js +1 -1
- package/lib/completion.js +2 -2
- package/lib/index.js +10 -0
- package/lib/opt.js +14 -1
- package/lib/shell.js +1 -2
- package/package.json +12 -4
- package/src/arg.coffee +15 -1
- package/src/cmd.coffee +77 -18
- package/src/index.coffee +5 -0
- package/src/opt.coffee +10 -0
- package/test/coa.js +496 -0
- package/test/common.js +1 -0
- package/test/mocha.opts +3 -0
- package/test/shell-test.js +43 -42
- package/tests/api-h.js +2 -2
- package/tests/h.js +1 -1
- package/lib/coa.js +0 -3
- package/src/coa.coffee +0 -1
- package/tests/a.js +0 -14
- package/tests/api-args.js +0 -34
- package/tests/api-cmd.js +0 -27
- package/tests/args.js +0 -21
- package/tests/cmd.js +0 -14
- package/tests/def.js +0 -25
- package/tests/l.js +0 -21
- package/tests/rarg.js +0 -13
- package/tests/req.js +0 -10
- package/tests/v.js +0 -23
- package/tests/val.js +0 -14
package/tests/api-cmd.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
var program = require('../lib/coa').Cmd()
|
2
|
-
.name('cmd')
|
3
|
-
.title('Command test')
|
4
|
-
.helpful()
|
5
|
-
.cmd()
|
6
|
-
.name('command')
|
7
|
-
.title('Do command work')
|
8
|
-
.helpful()
|
9
|
-
.cmd()
|
10
|
-
.name('subcommand')
|
11
|
-
.title('Do subcommand work')
|
12
|
-
.helpful()
|
13
|
-
.act(function() {
|
14
|
-
console.log('Doing subcommand work...');
|
15
|
-
})
|
16
|
-
.end()
|
17
|
-
.act(function() {
|
18
|
-
console.log('Doing a lot of command work...');
|
19
|
-
})
|
20
|
-
.end()
|
21
|
-
.act(function() {
|
22
|
-
console.log('Doing nothing...');
|
23
|
-
});
|
24
|
-
|
25
|
-
program.api().end();
|
26
|
-
program.api.command().end();
|
27
|
-
program.api.command.subcommand().end();
|
package/tests/args.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('arg')
|
4
|
-
.title('Args test')
|
5
|
-
.helpful()
|
6
|
-
.opt()
|
7
|
-
.name('opt').title('Option')
|
8
|
-
.long('opt').short('o')
|
9
|
-
.end()
|
10
|
-
.arg()
|
11
|
-
.name('arg1').title('First arg')
|
12
|
-
.end()
|
13
|
-
.arg()
|
14
|
-
.name('arg2').title('Second array arg')
|
15
|
-
.arr()
|
16
|
-
.end()
|
17
|
-
.act(function(opts, args) {
|
18
|
-
console.log(opts);
|
19
|
-
console.log(args);
|
20
|
-
})
|
21
|
-
.run(argv.length? argv : ['-o', 'value', 'value', 'value 1', 'value 2']);
|
package/tests/cmd.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('cmd')
|
4
|
-
.title('Command test')
|
5
|
-
.helpful()
|
6
|
-
.cmd()
|
7
|
-
.name('command')
|
8
|
-
.title('Do command work')
|
9
|
-
.helpful()
|
10
|
-
.act(function() {
|
11
|
-
console.log('Doing command work...');
|
12
|
-
})
|
13
|
-
.end()
|
14
|
-
.run(argv.length? argv : ['command']);
|
package/tests/def.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('def')
|
4
|
-
.title('Default value test')
|
5
|
-
.helpful()
|
6
|
-
.opt()
|
7
|
-
.name('a').title('Value A')
|
8
|
-
.short('a')
|
9
|
-
.def('aaa')
|
10
|
-
.act(function(opts) {
|
11
|
-
console.log('a=' + opts.a);
|
12
|
-
})
|
13
|
-
.end()
|
14
|
-
.opt()
|
15
|
-
.name('b').title('Value B')
|
16
|
-
.short('b')
|
17
|
-
.def('bbb')
|
18
|
-
.act(function(opts) {
|
19
|
-
console.log('b=' + opts.b);
|
20
|
-
})
|
21
|
-
.end()
|
22
|
-
.act(function(opts) {
|
23
|
-
console.log(opts);
|
24
|
-
})
|
25
|
-
.run(argv.length? argv : ['-a', '1']);
|
package/tests/l.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('bla')
|
4
|
-
.title('Bla bla bla')
|
5
|
-
.helpful()
|
6
|
-
.opt()
|
7
|
-
.name('long1').title('Long1')
|
8
|
-
.short('l').long('long1')
|
9
|
-
.act(function(opts) {
|
10
|
-
console.log(opts.long1);
|
11
|
-
})
|
12
|
-
.end()
|
13
|
-
.opt()
|
14
|
-
.name('long2').title('Long2')
|
15
|
-
.short('L').long('long2')
|
16
|
-
.act(function(opts) {
|
17
|
-
console.log(opts.long2);
|
18
|
-
})
|
19
|
-
.end()
|
20
|
-
.act(function(opts) { console.log(opts) })
|
21
|
-
.run(argv.length? argv : ['--long1', '111', '--long2', '222']);
|
package/tests/rarg.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('rarg')
|
4
|
-
.title('Raw arg test')
|
5
|
-
.helpful()
|
6
|
-
.arg()
|
7
|
-
.name('raw').title('Raw arg')
|
8
|
-
.arr()
|
9
|
-
.end()
|
10
|
-
.act(function(opts, args) {
|
11
|
-
console.log(args);
|
12
|
-
})
|
13
|
-
.run(argv.length? argv : ['--', 'raw', 'arg', 'values']);
|
package/tests/req.js
DELETED
package/tests/v.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('bla')
|
4
|
-
.title('Bla bla bla')
|
5
|
-
.helpful()
|
6
|
-
.opt()
|
7
|
-
.name('version').title('Version')
|
8
|
-
.short('v').long('version')
|
9
|
-
.flag()
|
10
|
-
.only()
|
11
|
-
.act(function(opts, args) {
|
12
|
-
return require('../package.json').version;
|
13
|
-
})
|
14
|
-
.end()
|
15
|
-
.opt()
|
16
|
-
.name('req').title('Required')
|
17
|
-
.short('r').long('long')
|
18
|
-
.req()
|
19
|
-
.end()
|
20
|
-
.act(function() {
|
21
|
-
console.log('... doing hard work ...')
|
22
|
-
})
|
23
|
-
.run(argv.length? argv : ['-v']);
|
package/tests/val.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
var argv = process.argv.slice(2);
|
2
|
-
require('../lib/coa').Cmd()
|
3
|
-
.name('val')
|
4
|
-
.title('Val test')
|
5
|
-
.helpful()
|
6
|
-
.opt()
|
7
|
-
.name('bla').title('Bla')
|
8
|
-
.short('b').long('bla')
|
9
|
-
.val(function(v) { return { value: v } })
|
10
|
-
.act(function(opts) {
|
11
|
-
console.log(opts.bla);
|
12
|
-
})
|
13
|
-
.end()
|
14
|
-
.run(argv.length? argv : ['--bla=blabla']);
|