-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
75 lines (68 loc) · 2.47 KB
/
main.go
File metadata and controls
75 lines (68 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Package broccli is meant to make handling command line interface easier.
// Define commands with arguments, flags, attach a handler to it and package will do all the parsing.
package broccli
// Command param type.
const (
_ = iota * 1
// ParamFlag sets param to be a command flag.
ParamFlag
// ParamFlag sets param to be a command arg.
ParamArg
// ParamFlag sets param to be an environment variable.
ParamEnvVar
)
// Value types.
const (
// TypeString requires param to be a string.
TypeString = iota * 1
// TypeBool requires param to be a boolean.
TypeBool
// TypeInt requires param to be an integer.
TypeInt
// TypeFloat requires param to be a float.
TypeFloat
// TypeAlphanumeric requires param to contain numbers and latin letters only.
TypeAlphanumeric
// TypePathFile requires param to be a path to a file.
TypePathFile
)
// Validation.
const (
_ = 1 << iota
// IsRequired means that the value is required.
IsRequired
// IsExistent is used with TypePathFile and requires file to exist.
IsExistent
// IsNotExistent is used with TypePathFile and requires file not to exist.
IsNotExistent
// IsDirectory is used with TypePathFile and requires file to be a directory.
IsDirectory
// IsRegularFile is used with TypePathFile and requires file to be a regular file.
IsRegularFile
// IsValidJSON is used with TypeString or TypePathFile with RegularFile to check if the contents are a valid JSON.
IsValidJSON
// AllowDots can be used only with TypeAlphanumeric and additionally allows flag to have dots.
AllowDots
// AllowUnderscore can be used only with TypeAlphanumeric and additionally allows flag to have underscore chars.
AllowUnderscore
// AllowHyphen can be used only with TypeAlphanumeric and additionally allows flag to have hyphen chars.
AllowHyphen
// AllowMultipleValues allows param to have more than one value separated by comma by default.
// For example: AllowMany with TypeInt allows values like: 123 or 123,455,666 or 12,222
// AllowMany works only with TypeInt, TypeFloat and TypeAlphanumeric.
AllowMultipleValues
// SeparatorColon works with AllowMultipleValues and sets colon to be the value separator, instead of colon.
SeparatorColon
// SeparatorSemiColon works with AllowMultipleValues and sets semi-colon to be the value separator.
SeparatorSemiColon
)
const (
tabWriterMinWidth = 8
tabWriterMinWidthForCommand = 10
tabWriterTabWidth = 8
tabWriterPadding = 8
tabWriterPadChar = '\t'
)
const (
maxArgs = 10
)