UNPKG

1.33 kBPlain TextView Raw
1#!/usr/bin/env node
2
3/**
4 * Command line interface of apeman-srch.
5 * This file is auto generated by ape-tmpl.
6 */
7
8"use strict";
9
10const program = require('commander'),
11 pkg = require('../package'),
12 apemanSrch = require('../lib');
13
14program
15 .version(pkg['version'])
16 .usage('[options] [term...] ')
17 .description("Search apeman modules.")
18 .option('-v, --verbose', "Show verbose logs")
19 .option('-t, --type <type>', "Type to search.")
20;
21
22
23//=========================
24// Show examples
25//=========================
26program.on('--help', () => {
27 console.log(' Examples:');
28 console.log('');
29 console.log(' $ apeman-srch # List all available packages.');
30 console.log(' $ apeman-srch -t task # List all available task packages.');
31 console.log(' $ apeman-srch -t task "foo" # List all available task which match term "foo".');
32 console.log('');
33});
34
35program.parse(process.argv);
36
37
38//=========================
39// Run main command
40//=========================
41
42apemanSrch.apply(apemanSrch, program.args.concat({
43 verbose: program.verbose,
44 type: program.type})
45).catch(handleError);
46
47
48//=========================
49// Handlers
50//=========================
51
52/** Handle error */
53function handleError(err) {
54 console.error(err);
55 process.exit(1);
56}