Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Apr 1, 2020. It is now read-only.
/dargPublic archive

Robust command line argument parsing for D.

License

NotificationsYou must be signed in to change notification settings

jasonwhite/darg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Better command line argument parsing using D's powerful compile-time codegeneration facilities.

Note: This is a stable library, but it is no longer maintained. If you'dlike to help out with maintanence please make an issue letting me know!

Example

importstd.stdio;import darg;structOptions{    @Option("help","h")    @Help("Prints this help.")    OptionFlag help;    @Option("threads","t")    @Help("Number of threads to use.")size_t threads;    @Argument("file", Multiplicity.zeroOrMore)    @Help("Input files")string[] files;}// Generate the usage and help string at compile time.immutable usage = usageString!Options("example");immutable help = helpString!Options;intmain(string[] args){    Options options;try    {        options = parseArgs!Options(args[1.. $]);    }catch (ArgParseError e)    {        writeln(e.msg);        writeln(usage);return1;    }catch (ArgParseHelp e)    {// Help was requested        writeln(usage);        write(help);return0;    }foreach (f; options.files)    {// Use files    }return0;}
$ ./example --helpUsage: example [--help] [--threads=<ulong>] [file...]Positional arguments: file            Input filesOptional arguments: --help, -h      Prints this help. --threads, -t <ulong>                 Number of threads to use.$ ./example --foobarUnknown option '--foobar'Usage: program [--help] [--threads=<ulong>] [file...]

License

MIT License

About

Robust command line argument parsing for D.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp