Skip to content

Commit

Permalink
add cli, ref #1
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Mar 2, 2015
1 parent 7071304 commit c8ef22d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
41 changes: 41 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env node
/**
* current-week-number <https://github.com/datetime/current-week-number>
*
* Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
* Released under the MIT license.
*/

'use strict';

var pkg = require('./package.json');
var currentWeekNumber = require('./');
var argv = process.argv.slice(2);

function help() {
console.log([
'',
' ' + pkg.description,
'',
' Example',
' $ current-week-number September 15, 2126',
' 37',
' $ current-week-number August 07, 2016',
' 32',
' $ current-week-number 02/17/2012',
' 7',
' $ current-week-number',
' 10'
].join('\n'));
}

if (argv.indexOf('--help') !== -1) {
return help();
}

if (argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}

console.log(currentWeekNumber(argv.join('')));
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test-travis": "istanbul cover _mocha --report lcovonly"
},
"author": {
"name": "Charlike Make Reagent",
"name": "Charlike Mike Reagent",
"email": "[email protected]",
"url": "https://github.com/tunnckoCore"
},
Expand Down Expand Up @@ -46,11 +46,12 @@
"type": "MIT",
"url": "https://github.com/datetime/current-week-number/blob/master/license.md"
},
"dependencies": {
"meow": "~3.0.0"
},
"dependencies": {},
"devDependencies": {
"istanbul-harmony": "~0.3.1",
"mocha": "~2.1.0"
},
"bin": {
"current-week-number": "cli.js"
}
}

0 comments on commit c8ef22d

Please sign in to comment.