/parseCommandLineArguments

Parse a string of command line arguments into positional and keyword parameters.

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

parseCommandLineArguments

Parse a string of command line arguments into positional and keyword parameters.

Test

const string  = "hello --person=name --location=world greeting -d1"

const results = {"keywords"   :
                   {"person"  : "name",
                    "location": "world",
                    "d"       : "1",
                   },
                 "positionals": ["hello","greeting"]}

assert.deepEqual(parseCommandLineArguments(string), results)