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 /** 12 * Command Line Help Message for the arugement. 13 */ 14 struct Help { 15 /** 16 * Help Message. 17 */ 18 string msg; 19 } 20 21 /** 22 * Command Line Argument Option which causes assignement to this field. 23 */ 24 struct Option { 25 /** 26 * All argument options. 27 */ 28 string[] names; 29 30 /** 31 * Construct all options into an array. 32 * 33 * ``` 34 * @Option("help", "h") 35 */ 36 this(string[] names...) { 37 this.names = names; 38 } 39 40 /** 41 * Used by generator to translate array into getopt argument. 42 */ 43 string cononical() { 44 import std.algorithm; 45 import std.conv; 46 return names.joiner("|").to!string; 47 } 48 /// 49 unittest { 50 auto opt = Option("help", "h"); 51 52 assert(opt.names == ["help", "h"]); 53 assert(opt.cononical() == "help|h"); 54 } 55 }