Skip to content

Instantly share code, notes, and snippets.

@fodra
Created November 30, 2017 03:38
Show Gist options
  • Save fodra/d2e8b7135fd2a910ff5a370e1dffc05b to your computer and use it in GitHub Desktop.
Save fodra/d2e8b7135fd2a910ff5a370e1dffc05b to your computer and use it in GitHub Desktop.
Sample usage of command-line-args and command-line-usage
const commandLineArgs = require("command-line-args");
const getUsage = require("command-line-usage");
const optionDefinitions = [
{ name: "folder", alias: "f", type: String },
{ name: "gpsfiles", alias: "g", multiple: true, defaultOption: true }
];
const sections = [
{
header: "Sportnut",
content: "This utility converts .GPS files from the SPT Bridge application to Excel(.XLSX) format files."
},
{
header: "Options",
optionList: [{
name: "gpsfiles",
typeLabel: "[underline]{file1} [underline]{file2} .. [underline]{fileN}",
description: "GPS files to convert."
}, {
name: "folder",
typeLabel: "[underline]{folder}",
description: "Folder path where the Excel files are saved."
}
]
}
];
const options = commandLineArgs(optionDefinitions);
const usage = getUsage(sections);
if (!options.gpsfiles) {
console.log(usage);
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment