1 module eph.args.param; 2 3 /** 4 * Positional Parameter 5 */ 6 public class Parameter { 7 8 private string n; 9 10 private string desc; 11 12 private bool req; 13 14 private string val; 15 16 private bool set; 17 18 /** 19 * Sets this parameter's display name. Used in the 20 * generation of help text. 21 */ 22 public Parameter name(string n) { 23 this.n = n; 24 return this; 25 } 26 27 /** 28 * Returns this parameter's display name. 29 */ 30 public string name() const { 31 return this.n; 32 } 33 34 /** 35 * Sets this Parameter's description. Used in the 36 * generation of help text. 37 */ 38 public Parameter description(string d) { 39 this.desc = d; 40 return this; 41 } 42 43 /** 44 * Returns this Parameter's description. 45 */ 46 public string description() const { 47 return this.desc; 48 } 49 50 /** 51 * Returns whether or not this Parameter has a description 52 * set. 53 */ 54 public bool hasDescription() const { 55 return this.desc != ""; 56 } 57 58 /** 59 * Sets this Parameter as required. 60 */ 61 public Parameter require() { 62 this.req = true; 63 return this; 64 } 65 66 /** 67 * Returns whether or not this Parameter is required. 68 */ 69 public bool required() const { 70 return this.req; 71 } 72 73 /** 74 * Returns the value parsed from the command call. 75 */ 76 public string value() const { 77 return this.val; 78 } 79 80 /** 81 * Returns whether or not this Parameter was set in the 82 * command call. 83 */ 84 public bool wasSet() const { 85 return this.set; 86 } 87 88 /** 89 * Mark this Parameter as having been used in the command 90 * call. 91 */ 92 package void setWasSet(bool set) { 93 this.set = set; 94 } 95 96 /** 97 * Sets the command call value for this Parameter. 98 */ 99 package void value(string val) { 100 this.val = val; 101 } 102 }