Skip to content

DruSatori/CommandLineOptions

Repository files navigation

CommandLineOptions

A simple, easy to use method of parsing command line options. It quickly parses an array of strings from the command line into a key/value pair dictionary.

Any key with a -- or - prefix is parsed as a key. If there is an embedded = the key and value are split from that with the key being the left side and the value being the right. Absent an = sign, the next entry in the string array is the value. If there is no value, the key is writte to the key value pair as having a value of 'true'.

In order to add friendly name properties, simply create an extension that wraps properties around the key names. In the library, there is a HelpOptions and LoginOptions extension already in place to handle --user, --password, --host, --help and --verbose(-v) options.

import CommandLineOptions

let opts : Options = Options(args: CommandLine.arguments)

if (opts.verbose) {
    print("Verbose is enabled")
}

http://www.druware.com/product/swift-clo

About

A simple Swift Package for parsing command line options in a lazy manner. It is neither elegant, nor the fastest, just easy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages