1package cli
2
3import (
4 "flag"
5 "strconv"
6 "time"
7)
8
9// WARNING: This file is generated!
10
11// BoolFlag is a flag with type bool
12type BoolFlag struct {
13 Name string
14 Usage string
15 EnvVar string
16 Hidden bool
17 Destination *bool
18}
19
20// String returns a readable representation of this value
21// (for usage defaults)
22func (f BoolFlag) String() string {
23 return FlagStringer(f)
24}
25
26// GetName returns the name of the flag
27func (f BoolFlag) GetName() string {
28 return f.Name
29}
30
31// Bool looks up the value of a local BoolFlag, returns
32// false if not found
33func (c *Context) Bool(name string) bool {
34 return lookupBool(name, c.flagSet)
35}
36
37// GlobalBool looks up the value of a global BoolFlag, returns
38// false if not found
39func (c *Context) GlobalBool(name string) bool {
40 if fs := lookupGlobalFlagSet(name, c); fs != nil {
41 return lookupBool(name, fs)
42 }
43 return false
44}
45
46func lookupBool(name string, set *flag.FlagSet) bool {
47 f := set.Lookup(name)
48 if f != nil {
49 parsed, err := strconv.ParseBool(f.Value.String())
50 if err != nil {
51 return false
52 }
53 return parsed
54 }
55 return false
56}
57
58// BoolTFlag is a flag with type bool that is true by default
59type BoolTFlag struct {
60 Name string
61 Usage string
62 EnvVar string
63 Hidden bool
64 Destination *bool
65}
66
67// String returns a readable representation of this value
68// (for usage defaults)
69func (f BoolTFlag) String() string {
70 return FlagStringer(f)
71}
72
73// GetName returns the name of the flag
74func (f BoolTFlag) GetName() string {
75 return f.Name
76}
77
78// BoolT looks up the value of a local BoolTFlag, returns
79// false if not found
80func (c *Context) BoolT(name string) bool {
81 return lookupBoolT(name, c.flagSet)
82}
83
84// GlobalBoolT looks up the value of a global BoolTFlag, returns
85// false if not found
86func (c *Context) GlobalBoolT(name string) bool {
87 if fs := lookupGlobalFlagSet(name, c); fs != nil {
88 return lookupBoolT(name, fs)
89 }
90 return false
91}
92
93func lookupBoolT(name string, set *flag.FlagSet) bool {
94 f := set.Lookup(name)
95 if f != nil {
96 parsed, err := strconv.ParseBool(f.Value.String())
97 if err != nil {
98 return false
99 }
100 return parsed
101 }
102 return false
103}
104
105// DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration)
106type DurationFlag struct {
107 Name string
108 Usage string
109 EnvVar string
110 Hidden bool
111 Value time.Duration
112 Destination *time.Duration
113}
114
115// String returns a readable representation of this value
116// (for usage defaults)
117func (f DurationFlag) String() string {
118 return FlagStringer(f)
119}
120
121// GetName returns the name of the flag
122func (f DurationFlag) GetName() string {
123 return f.Name
124}
125
126// Duration looks up the value of a local DurationFlag, returns
127// 0 if not found
128func (c *Context) Duration(name string) time.Duration {
129 return lookupDuration(name, c.flagSet)
130}
131
132// GlobalDuration looks up the value of a global DurationFlag, returns
133// 0 if not found
134func (c *Context) GlobalDuration(name string) time.Duration {
135 if fs := lookupGlobalFlagSet(name, c); fs != nil {
136 return lookupDuration(name, fs)
137 }
138 return 0
139}
140
141func lookupDuration(name string, set *flag.FlagSet) time.Duration {
142 f := set.Lookup(name)
143 if f != nil {
144 parsed, err := time.ParseDuration(f.Value.String())
145 if err != nil {
146 return 0
147 }
148 return parsed
149 }
150 return 0
151}
152
153// Float64Flag is a flag with type float64
154type Float64Flag struct {
155 Name string
156 Usage string
157 EnvVar string
158 Hidden bool
159 Value float64
160 Destination *float64
161}
162
163// String returns a readable representation of this value
164// (for usage defaults)
165func (f Float64Flag) String() string {
166 return FlagStringer(f)
167}
168
169// GetName returns the name of the flag
170func (f Float64Flag) GetName() string {
171 return f.Name
172}
173
174// Float64 looks up the value of a local Float64Flag, returns
175// 0 if not found
176func (c *Context) Float64(name string) float64 {
177 return lookupFloat64(name, c.flagSet)
178}
179
180// GlobalFloat64 looks up the value of a global Float64Flag, returns
181// 0 if not found
182func (c *Context) GlobalFloat64(name string) float64 {
183 if fs := lookupGlobalFlagSet(name, c); fs != nil {
184 return lookupFloat64(name, fs)
185 }
186 return 0
187}
188
189func lookupFloat64(name string, set *flag.FlagSet) float64 {
190 f := set.Lookup(name)
191 if f != nil {
192 parsed, err := strconv.ParseFloat(f.Value.String(), 64)
193 if err != nil {
194 return 0
195 }
196 return parsed
197 }
198 return 0
199}
200
201// GenericFlag is a flag with type Generic
202type GenericFlag struct {
203 Name string
204 Usage string
205 EnvVar string
206 Hidden bool
207 Value Generic
208}
209
210// String returns a readable representation of this value
211// (for usage defaults)
212func (f GenericFlag) String() string {
213 return FlagStringer(f)
214}
215
216// GetName returns the name of the flag
217func (f GenericFlag) GetName() string {
218 return f.Name
219}
220
221// Generic looks up the value of a local GenericFlag, returns
222// nil if not found
223func (c *Context) Generic(name string) interface{} {
224 return lookupGeneric(name, c.flagSet)
225}
226
227// GlobalGeneric looks up the value of a global GenericFlag, returns
228// nil if not found
229func (c *Context) GlobalGeneric(name string) interface{} {
230 if fs := lookupGlobalFlagSet(name, c); fs != nil {
231 return lookupGeneric(name, fs)
232 }
233 return nil
234}
235
236func lookupGeneric(name string, set *flag.FlagSet) interface{} {
237 f := set.Lookup(name)
238 if f != nil {
239 parsed, err := f.Value, error(nil)
240 if err != nil {
241 return nil
242 }
243 return parsed
244 }
245 return nil
246}
247
248// Int64Flag is a flag with type int64
249type Int64Flag struct {
250 Name string
251 Usage string
252 EnvVar string
253 Hidden bool
254 Value int64
255 Destination *int64
256}
257
258// String returns a readable representation of this value
259// (for usage defaults)
260func (f Int64Flag) String() string {
261 return FlagStringer(f)
262}
263
264// GetName returns the name of the flag
265func (f Int64Flag) GetName() string {
266 return f.Name
267}
268
269// Int64 looks up the value of a local Int64Flag, returns
270// 0 if not found
271func (c *Context) Int64(name string) int64 {
272 return lookupInt64(name, c.flagSet)
273}
274
275// GlobalInt64 looks up the value of a global Int64Flag, returns
276// 0 if not found
277func (c *Context) GlobalInt64(name string) int64 {
278 if fs := lookupGlobalFlagSet(name, c); fs != nil {
279 return lookupInt64(name, fs)
280 }
281 return 0
282}
283
284func lookupInt64(name string, set *flag.FlagSet) int64 {
285 f := set.Lookup(name)
286 if f != nil {
287 parsed, err := strconv.ParseInt(f.Value.String(), 0, 64)
288 if err != nil {
289 return 0
290 }
291 return parsed
292 }
293 return 0
294}
295
296// IntFlag is a flag with type int
297type IntFlag struct {
298 Name string
299 Usage string
300 EnvVar string
301 Hidden bool
302 Value int
303 Destination *int
304}
305
306// String returns a readable representation of this value
307// (for usage defaults)
308func (f IntFlag) String() string {
309 return FlagStringer(f)
310}
311
312// GetName returns the name of the flag
313func (f IntFlag) GetName() string {
314 return f.Name
315}
316
317// Int looks up the value of a local IntFlag, returns
318// 0 if not found
319func (c *Context) Int(name string) int {
320 return lookupInt(name, c.flagSet)
321}
322
323// GlobalInt looks up the value of a global IntFlag, returns
324// 0 if not found
325func (c *Context) GlobalInt(name string) int {
326 if fs := lookupGlobalFlagSet(name, c); fs != nil {
327 return lookupInt(name, fs)
328 }
329 return 0
330}
331
332func lookupInt(name string, set *flag.FlagSet) int {
333 f := set.Lookup(name)
334 if f != nil {
335 parsed, err := strconv.ParseInt(f.Value.String(), 0, 64)
336 if err != nil {
337 return 0
338 }
339 return int(parsed)
340 }
341 return 0
342}
343
344// IntSliceFlag is a flag with type *IntSlice
345type IntSliceFlag struct {
346 Name string
347 Usage string
348 EnvVar string
349 Hidden bool
350 Value *IntSlice
351}
352
353// String returns a readable representation of this value
354// (for usage defaults)
355func (f IntSliceFlag) String() string {
356 return FlagStringer(f)
357}
358
359// GetName returns the name of the flag
360func (f IntSliceFlag) GetName() string {
361 return f.Name
362}
363
364// IntSlice looks up the value of a local IntSliceFlag, returns
365// nil if not found
366func (c *Context) IntSlice(name string) []int {
367 return lookupIntSlice(name, c.flagSet)
368}
369
370// GlobalIntSlice looks up the value of a global IntSliceFlag, returns
371// nil if not found
372func (c *Context) GlobalIntSlice(name string) []int {
373 if fs := lookupGlobalFlagSet(name, c); fs != nil {
374 return lookupIntSlice(name, fs)
375 }
376 return nil
377}
378
379func lookupIntSlice(name string, set *flag.FlagSet) []int {
380 f := set.Lookup(name)
381 if f != nil {
382 parsed, err := (f.Value.(*IntSlice)).Value(), error(nil)
383 if err != nil {
384 return nil
385 }
386 return parsed
387 }
388 return nil
389}
390
391// Int64SliceFlag is a flag with type *Int64Slice
392type Int64SliceFlag struct {
393 Name string
394 Usage string
395 EnvVar string
396 Hidden bool
397 Value *Int64Slice
398}
399
400// String returns a readable representation of this value
401// (for usage defaults)
402func (f Int64SliceFlag) String() string {
403 return FlagStringer(f)
404}
405
406// GetName returns the name of the flag
407func (f Int64SliceFlag) GetName() string {
408 return f.Name
409}
410
411// Int64Slice looks up the value of a local Int64SliceFlag, returns
412// nil if not found
413func (c *Context) Int64Slice(name string) []int64 {
414 return lookupInt64Slice(name, c.flagSet)
415}
416
417// GlobalInt64Slice looks up the value of a global Int64SliceFlag, returns
418// nil if not found
419func (c *Context) GlobalInt64Slice(name string) []int64 {
420 if fs := lookupGlobalFlagSet(name, c); fs != nil {
421 return lookupInt64Slice(name, fs)
422 }
423 return nil
424}
425
426func lookupInt64Slice(name string, set *flag.FlagSet) []int64 {
427 f := set.Lookup(name)
428 if f != nil {
429 parsed, err := (f.Value.(*Int64Slice)).Value(), error(nil)
430 if err != nil {
431 return nil
432 }
433 return parsed
434 }
435 return nil
436}
437
438// StringFlag is a flag with type string
439type StringFlag struct {
440 Name string
441 Usage string
442 EnvVar string
443 Hidden bool
444 Value string
445 Destination *string
446}
447
448// String returns a readable representation of this value
449// (for usage defaults)
450func (f StringFlag) String() string {
451 return FlagStringer(f)
452}
453
454// GetName returns the name of the flag
455func (f StringFlag) GetName() string {
456 return f.Name
457}
458
459// String looks up the value of a local StringFlag, returns
460// "" if not found
461func (c *Context) String(name string) string {
462 return lookupString(name, c.flagSet)
463}
464
465// GlobalString looks up the value of a global StringFlag, returns
466// "" if not found
467func (c *Context) GlobalString(name string) string {
468 if fs := lookupGlobalFlagSet(name, c); fs != nil {
469 return lookupString(name, fs)
470 }
471 return ""
472}
473
474func lookupString(name string, set *flag.FlagSet) string {
475 f := set.Lookup(name)
476 if f != nil {
477 parsed, err := f.Value.String(), error(nil)
478 if err != nil {
479 return ""
480 }
481 return parsed
482 }
483 return ""
484}
485
486// StringSliceFlag is a flag with type *StringSlice
487type StringSliceFlag struct {
488 Name string
489 Usage string
490 EnvVar string
491 Hidden bool
492 Value *StringSlice
493}
494
495// String returns a readable representation of this value
496// (for usage defaults)
497func (f StringSliceFlag) String() string {
498 return FlagStringer(f)
499}
500
501// GetName returns the name of the flag
502func (f StringSliceFlag) GetName() string {
503 return f.Name
504}
505
506// StringSlice looks up the value of a local StringSliceFlag, returns
507// nil if not found
508func (c *Context) StringSlice(name string) []string {
509 return lookupStringSlice(name, c.flagSet)
510}
511
512// GlobalStringSlice looks up the value of a global StringSliceFlag, returns
513// nil if not found
514func (c *Context) GlobalStringSlice(name string) []string {
515 if fs := lookupGlobalFlagSet(name, c); fs != nil {
516 return lookupStringSlice(name, fs)
517 }
518 return nil
519}
520
521func lookupStringSlice(name string, set *flag.FlagSet) []string {
522 f := set.Lookup(name)
523 if f != nil {
524 parsed, err := (f.Value.(*StringSlice)).Value(), error(nil)
525 if err != nil {
526 return nil
527 }
528 return parsed
529 }
530 return nil
531}
532
533// Uint64Flag is a flag with type uint64
534type Uint64Flag struct {
535 Name string
536 Usage string
537 EnvVar string
538 Hidden bool
539 Value uint64
540 Destination *uint64
541}
542
543// String returns a readable representation of this value
544// (for usage defaults)
545func (f Uint64Flag) String() string {
546 return FlagStringer(f)
547}
548
549// GetName returns the name of the flag
550func (f Uint64Flag) GetName() string {
551 return f.Name
552}
553
554// Uint64 looks up the value of a local Uint64Flag, returns
555// 0 if not found
556func (c *Context) Uint64(name string) uint64 {
557 return lookupUint64(name, c.flagSet)
558}
559
560// GlobalUint64 looks up the value of a global Uint64Flag, returns
561// 0 if not found
562func (c *Context) GlobalUint64(name string) uint64 {
563 if fs := lookupGlobalFlagSet(name, c); fs != nil {
564 return lookupUint64(name, fs)
565 }
566 return 0
567}
568
569func lookupUint64(name string, set *flag.FlagSet) uint64 {
570 f := set.Lookup(name)
571 if f != nil {
572 parsed, err := strconv.ParseUint(f.Value.String(), 0, 64)
573 if err != nil {
574 return 0
575 }
576 return parsed
577 }
578 return 0
579}
580
581// UintFlag is a flag with type uint
582type UintFlag struct {
583 Name string
584 Usage string
585 EnvVar string
586 Hidden bool
587 Value uint
588 Destination *uint
589}
590
591// String returns a readable representation of this value
592// (for usage defaults)
593func (f UintFlag) String() string {
594 return FlagStringer(f)
595}
596
597// GetName returns the name of the flag
598func (f UintFlag) GetName() string {
599 return f.Name
600}
601
602// Uint looks up the value of a local UintFlag, returns
603// 0 if not found
604func (c *Context) Uint(name string) uint {
605 return lookupUint(name, c.flagSet)
606}
607
608// GlobalUint looks up the value of a global UintFlag, returns
609// 0 if not found
610func (c *Context) GlobalUint(name string) uint {
611 if fs := lookupGlobalFlagSet(name, c); fs != nil {
612 return lookupUint(name, fs)
613 }
614 return 0
615}
616
617func lookupUint(name string, set *flag.FlagSet) uint {
618 f := set.Lookup(name)
619 if f != nil {
620 parsed, err := strconv.ParseUint(f.Value.String(), 0, 64)
621 if err != nil {
622 return 0
623 }
624 return uint(parsed)
625 }
626 return 0
627}