diff --git a/cli.js b/cli.js new file mode 100755 index 0000000..ec8f16d --- /dev/null +++ b/cli.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node +'use strict'; + +var pkg = require('./package.json'); +var currentDayNumber = require('./'); +var argv = process.argv.slice(2); + +function help() { + console.log([ + '', + ' ' + pkg.description, + '', + ' Example', + ' $ current-day-number', + ' 47' + ].join('\n')); +} + +if (argv.indexOf('--help') !== -1) { + return help(); +} + +if (argv.indexOf('--version') !== -1) { + return console.log(pkg.version); +} + +console.log(currentDayNumber(argv.join(''))); diff --git a/package.json b/package.json index efdba08..bfebce1 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,9 @@ "year", "years" ], + "bin": { + "current-day-number": "cli.js" + }, "license": { "type": "MIT", "url": "https://github.com/datetime/current-day-number/blob/master/license.md" @@ -59,4 +62,4 @@ "mocha": "*", "mocha-lcov-reporter": "^0.0.1" } -} \ No newline at end of file +}