1 /** 2 * Compile Time attributes for specifying proprites to std.getopt. 3 * 4 * These structs are utilized by the the generator to populate 5 * getopt's properties. 6 */ 7 module structopt.attributes; 8 9 import std.traits; 10 11 @safe: 12 13 /** 14 * Command Line Help Message for the arugement. 15 */ 16 struct Help { 17 /** 18 * Help Message. 19 */ 20 string msg; 21 } 22 23 /** 24 * Command Line Argument Option which causes assignement to this field. 25 */ 26 struct Option { 27 @safe: 28 /** 29 * All argument options. 30 */ 31 string[] names; 32 33 /** 34 * Construct all options into an array. 35 * 36 * ``` 37 * @Option("help", "h") 38 */ 39 this(string[] names...) { 40 this.names = names.dup; 41 } 42 43 /** 44 * Used by generator to translate array into getopt argument. 45 */ 46 string cononical() { 47 import std.algorithm; 48 import std.conv; 49 return names.joiner("|").to!string; 50 } 51 /// 52 unittest { 53 auto opt = Option("help", "h"); 54 55 assert(opt.names == ["help", "h"]); 56 assert(opt.cononical() == "help|h"); 57 } 58 }