diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-12-28 11:47:38 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-12-28 11:47:38 +0000 |
| commit | b077df1b5a6736e250c1e054924e7cc0f1d0f0c3 (patch) | |
| tree | eddd78c61bcedb07263a63495815c6b8f88abb1d /bin | |
| parent | 53f620f1dc69b03b358f5eb4e20f0a69eba467c4 (diff) | |
Replace nomnom with argparse
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/mammoth | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/bin/mammoth b/bin/mammoth index 72d2af0..6fddaeb 100755 --- a/bin/mammoth +++ b/bin/mammoth @@ -1,31 +1,38 @@ #!/usr/bin/env node -var args = require("nomnom") - .option("docx-path", { - position: 0, - required: true, - type: "string", - help: "Path to the .docx file to convert." - }) - .option("output-path", { - position: 1, - type: "string", - help: "Output path for the generated document. Images will be stored inline in the output document. Output is written to stdout if not set." - }) - .option("output-dir", { - type: "string", - help: "Output directory for generated HTML and images. Images will be stored in separate files. Takes precedence over output-path." - }) - .option("output-format", { - default: "html", - choices: ["html", "markdown"], - help: "Output format." - }) - .option("style-map", { - type: "string", - help: "File containg a style map." - }) - .parse(); +var ArgumentParser = require("argparse").ArgumentParser; var main = require("../lib/main"); -main(args); +var parser = new ArgumentParser({ + addHelp: true +}); + +parser.addArgument(["docx-path"], { + type: "string", + help: "Path to the .docx file to convert." +}); + +var outputGroup = parser.addMutuallyExclusiveGroup(); +outputGroup.addArgument(["output-path"], { + type: "string", + nargs: "?", + help: "Output path for the generated document. Images will be stored inline in the output document. Output is written to stdout if not set." +}); +outputGroup.addArgument(["--output-dir"], { + type: "string", + help: "Output directory for generated HTML and images. Images will be stored in separate files. Takes precedence over output-path." +}); + +parser.addArgument(["--output-format"], { + defaultValue: "html", + choices: ["html", "markdown"], + help: "Output format." +}); + +parser.addArgument(["--style-map"], { + type: "string", + help: "File containg a style map." +}); + + +main(parser.parseArgs()); |
