github.com/goravel/framework@v1.13.9/contracts/console/command/command.go (about) 1 package command 2 3 const ( 4 FlagTypeBool = "bool" 5 FlagTypeFloat64 = "float64" 6 FlagTypeFloat64Slice = "float64_slice" 7 FlagTypeInt = "int" 8 FlagTypeIntSlice = "int_slice" 9 FlagTypeInt64 = "int64" 10 FlagTypeInt64Slice = "int64_slice" 11 FlagTypeString = "string" 12 FlagTypeStringSlice = "string_slice" 13 ) 14 15 type Extend struct { 16 Category string 17 Flags []Flag 18 } 19 20 type Flag interface { 21 // Type gets a flag type. 22 Type() string 23 } 24 25 type BoolFlag struct { 26 Name string 27 Aliases []string 28 Usage string 29 Required bool 30 Value bool 31 } 32 33 func (receiver *BoolFlag) Type() string { 34 return FlagTypeBool 35 } 36 37 type Float64Flag struct { 38 Name string 39 Aliases []string 40 Usage string 41 Required bool 42 Value float64 43 } 44 45 func (receiver *Float64Flag) Type() string { 46 return FlagTypeFloat64 47 } 48 49 type Float64SliceFlag struct { 50 Name string 51 Aliases []string 52 Usage string 53 Required bool 54 Value []float64 55 } 56 57 func (receiver *Float64SliceFlag) Type() string { 58 return FlagTypeFloat64Slice 59 } 60 61 type IntFlag struct { 62 Name string 63 Aliases []string 64 Usage string 65 Required bool 66 Value int 67 } 68 69 func (receiver *IntFlag) Type() string { 70 return FlagTypeInt 71 } 72 73 type IntSliceFlag struct { 74 Name string 75 Aliases []string 76 Usage string 77 Required bool 78 Value []int 79 } 80 81 func (receiver *IntSliceFlag) Type() string { 82 return FlagTypeIntSlice 83 } 84 85 type Int64Flag struct { 86 Name string 87 Aliases []string 88 Usage string 89 Required bool 90 Value int64 91 } 92 93 func (receiver *Int64Flag) Type() string { 94 return FlagTypeInt64 95 } 96 97 type Int64SliceFlag struct { 98 Name string 99 Aliases []string 100 Usage string 101 Required bool 102 Value []int64 103 } 104 105 func (receiver *Int64SliceFlag) Type() string { 106 return FlagTypeInt64Slice 107 } 108 109 type StringFlag struct { 110 Name string 111 Aliases []string 112 Usage string 113 Required bool 114 Value string 115 } 116 117 func (receiver *StringFlag) Type() string { 118 return FlagTypeString 119 } 120 121 type StringSliceFlag struct { 122 Name string 123 Aliases []string 124 Usage string 125 Required bool 126 Value []string 127 } 128 129 func (receiver *StringSliceFlag) Type() string { 130 return FlagTypeStringSlice 131 }