1 | #!/usr/bin/env node
|
2 | 'use strict';
|
3 |
|
4 | var pkg = require('../package.json');
|
5 | var commands = require('../lib/commands.js');
|
6 |
|
7 | var program = require('commander');
|
8 | var prompt = require('prompt');
|
9 |
|
10 | function callback(err, success){
|
11 | if (err) {
|
12 | return console.log('ERROR: '+err);
|
13 | } else if (success) {
|
14 | console.log(success);
|
15 | }
|
16 | }
|
17 |
|
18 | program.version(pkg.version);
|
19 |
|
20 | program
|
21 | .command('init')
|
22 | .description('Create the CHANGELOG.md in the current directory')
|
23 | .action(function(args){
|
24 | commands.init({}, callback);
|
25 | });
|
26 |
|
27 | program
|
28 | .command('add [line]')
|
29 | .description('Add one line to the changelog')
|
30 | .action(function(line, info){
|
31 | commands.add(line, {}, callback);
|
32 | });
|
33 |
|
34 | program
|
35 | .command('release [version]')
|
36 | .description('Move unreleased changes under a new release heading')
|
37 | .option('-d, --date [date]', 'Specify a date (defaults to today)')
|
38 | .action(function(version, info){
|
39 | var options = {};
|
40 |
|
41 | if (info.date) {
|
42 | options.date = info.date;
|
43 | }
|
44 |
|
45 | commands.release(version, options, callback);
|
46 | });
|
47 |
|
48 | program
|
49 | .command('delete')
|
50 | .description('Delete the changelog')
|
51 | .action(function(info){
|
52 | commands.delete({}, callback);
|
53 | });
|
54 |
|
55 | program.parse(process.argv);
|
56 |
|
57 | // default to help if no commands
|
58 | if (program.args.length === 0) {
|
59 | program.help();
|
60 | } |
\ | No newline at end of file |