-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce69059
commit 3b25f57
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,55 @@ | ||
/** | ||
* Compile Time attributes for specifying proprites to std.getopt. | ||
* | ||
* These structs are utilized by the the generator to populate | ||
* getopt's properties. | ||
*/ | ||
module structopt.attributes; | ||
|
||
import std.traits; | ||
|
||
/** | ||
* Command Line Help Message for the arugement. | ||
*/ | ||
struct Help { | ||
/** | ||
* Help Message. | ||
*/ | ||
string msg; | ||
} | ||
|
||
/** | ||
* Command Line Argument Option which causes assignement to this field. | ||
*/ | ||
struct Option { | ||
/** | ||
* All argument options. | ||
*/ | ||
string[] names; | ||
|
||
/** | ||
* Construct all options into an array. | ||
* | ||
* ``` | ||
* @Option("help", "h") | ||
*/ | ||
this(string[] names...) { | ||
this.names = names; | ||
} | ||
|
||
/** | ||
* Used by generator to translate array into getopt argument. | ||
*/ | ||
string cononical() { | ||
import std.algorithm; | ||
import std.conv; | ||
return names.joiner("|").to!string; | ||
} | ||
/// | ||
unittest { | ||
auto opt = Option("help", "h"); | ||
|
||
assert(opt.names == ["help", "h"]); | ||
assert(opt.cononical() == "help|h"); | ||
} | ||
} |
This file contains 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