Comparing version 0.2.3 to 0.2.4
@@ -37,47 +37,31 @@ #!/usr/bin/env node | ||
var optimist = require("optimist"); | ||
var program = require("commander"); | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var literate = require("../lib/literate.js"); | ||
optimist.usage("ljs [options] file.js"); | ||
var pkgJson = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json")).toString()); | ||
optimist.boolean("h").options("h", { | ||
alias: "help", | ||
describe: "Show brief help information", | ||
}); | ||
function toBool(x) { | ||
if (x === "true") { | ||
return true; | ||
} else if (x === "false") { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
optimist.boolean("v").options("v", { | ||
alias: "version", | ||
describe: "Display version information and exit.", | ||
}); | ||
program.usage("[options] file.js"); | ||
program.version(pkgJson.version); | ||
program.option("-o, --output <file>", "Output file"); | ||
program.option("-c, --code <switch>", "Include code in output file", toBool); | ||
optimist.options("o", { | ||
alias: "output", | ||
describe: "Output file.", | ||
}); | ||
optimist.boolean("c").options("c", { | ||
alias: "code", | ||
describe: "Include code in output file.", | ||
default: true, | ||
}); | ||
function cli(argv) { | ||
var options = optimist.parse(argv); | ||
program.parse(argv); | ||
if (options.help) { | ||
console.log(optimist.help()); | ||
return 0; | ||
} | ||
if (options.version) { | ||
var pkg = JSON.parse(fs.readFileSync(__dirname + "/../package.json")); | ||
console.log("jsgrep, part of jsstana version " + pkg.version); | ||
return 0; | ||
} | ||
if (options._.length !== 1) { | ||
if (program.args.length !== 1) { | ||
console.error("Error: input file is required"); | ||
console.log(optimist.help()); | ||
console.log(program.help()); | ||
return 0; | ||
@@ -87,6 +71,6 @@ } | ||
// Literate | ||
var filename = options._[0]; | ||
var filename = program.args[0]; | ||
var litContents; | ||
try { | ||
litContents = literate(filename, { code: options.code }); | ||
litContents = literate(filename, { code: program.code }); | ||
} catch (e) { | ||
@@ -98,4 +82,4 @@ console.error("Error: while literating -- " + e.message); | ||
// Output | ||
if (options.o) { | ||
fs.writeFileSync(options.o, litContents); | ||
if (program.output) { | ||
fs.writeFileSync(program.output, litContents); | ||
} else { | ||
@@ -106,3 +90,3 @@ console.log(litContents); | ||
var ret = cli(process.argv.slice(2)); | ||
var ret = cli(process.argv); | ||
process.exit(ret); |
{ | ||
"name": "ljs", | ||
"description": "Generate docs from your source", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/phadej/ljs", | ||
@@ -46,3 +46,3 @@ "author": { | ||
"esprima": "~1.2.2", | ||
"optimist": "~0.6.0", | ||
"commander": "~2.3.0", | ||
"glob": "~4.0.2", | ||
@@ -49,0 +49,0 @@ "underscore": "~1.6.0" |
@@ -31,2 +31,3 @@ # ljs | ||
- 0.2.4 Use commander | ||
- 0.2.3 Strip only empty lines from beginning of code blocks | ||
@@ -33,0 +34,0 @@ - 0.2.2 Whitespace handling for included files |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73
12830
287
+ Addedcommander@~2.3.0
+ Addedcommander@2.3.0(transitive)
- Removedoptimist@~0.6.0
- Removedminimist@0.0.10(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedwordwrap@0.0.3(transitive)