Created
November 30, 2017 03:38
-
-
Save fodra/d2e8b7135fd2a910ff5a370e1dffc05b to your computer and use it in GitHub Desktop.
Sample usage of command-line-args and command-line-usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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