-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvargus.v
70 lines (61 loc) · 1.74 KB
/
vargus.v
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
module vargus
// function type
type CmdFunction = fn (args []string, flags []FlagArgs)
// THIS IS NOT WORKING: ==> type HelpFunc = fn (a string, b string, x []HelpSubcommands, y []FlagArgs, z []FlagArgs)
type ValidatorFunc = fn (string) bool
type ErrorFuncImp = fn (string, string)
type ErrorFuncDef = fn (string)
struct Commander {
command string
short_desc string
long_desc string
allow_next_args bool
mut:
is_root bool
function CmdFunction
exec_func bool
config CommandConfig
flags []FlagArgs
global_flags []FlagArgs
global_flags_string []string
sub_commands []&Commander
sub_commands_string []string
hooks CmdHooks
persistent_hooks PersistentCmdHooks
}
// STRUCTS FOR APP CLI CONFIGURATIONS
// NOTE: THIS MIGHT BE REMOVED OR CHANGED IN THE FUTURE
pub struct CmdHooksConfig {
pre_run CmdFunction
post_run CmdFunction
persistent_pre_run CmdFunction
persistent_post_run CmdFunction
}
pub struct CmdConfig {
command string
short_desc string
long_desc string
allow_next_args bool = true // defaults to true
function CmdFunction
hooks CmdHooksConfig
config CommandCmdConfig
}
pub struct CommandCmdConfig {
help fn (string, string, []HelpSubcommands, []FlagArgs, []FlagArgs)
errors CmdErrorsConfig
validators CmdValidatorsConfig
}
pub struct CmdErrorsConfig {
required ErrorFuncImp
value ErrorFuncImp
blank ErrorFuncDef
unknown ErrorFuncDef
command ErrorFuncDef
}
pub struct CmdValidatorsConfig {
integer ValidatorFunc
string_var ValidatorFunc
float ValidatorFunc
boolean ValidatorFunc
}
// END STRUCTS FOR APP CLI CONFIGURATIONS