mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: check (mut f Foo)
syntax
This commit is contained in:
@ -34,15 +34,15 @@ pub fn (cmd Command) root() Command {
|
||||
return cmd.parent.root()
|
||||
}
|
||||
|
||||
pub fn (cmd mut Command) add_command(command Command) {
|
||||
pub fn (mut cmd Command) add_command(command Command) {
|
||||
cmd.commands << command
|
||||
}
|
||||
|
||||
pub fn (cmd mut Command) add_flag(flag Flag) {
|
||||
pub fn (mut cmd Command) add_flag(flag Flag) {
|
||||
cmd.flags << flag
|
||||
}
|
||||
|
||||
pub fn (cmd mut Command) parse(args []string) {
|
||||
pub fn (mut cmd Command) parse(args []string) {
|
||||
cmd.add_default_flags()
|
||||
cmd.add_default_commands()
|
||||
|
||||
@ -55,7 +55,7 @@ pub fn (cmd mut Command) parse(args []string) {
|
||||
cmd.parse_commands()
|
||||
}
|
||||
|
||||
fn (cmd mut Command) add_default_flags() {
|
||||
fn (mut cmd Command) add_default_flags() {
|
||||
if !cmd.disable_help && !cmd.flags.contains('help') && !cmd.flags.contains('h') {
|
||||
cmd.add_flag(help_flag())
|
||||
}
|
||||
@ -64,7 +64,7 @@ fn (cmd mut Command) add_default_flags() {
|
||||
}
|
||||
}
|
||||
|
||||
fn (cmd mut Command) add_default_commands() {
|
||||
fn (mut cmd Command) add_default_commands() {
|
||||
if !cmd.disable_help && !cmd.commands.contains('help') {
|
||||
cmd.add_command(help_cmd())
|
||||
}
|
||||
@ -73,7 +73,7 @@ fn (cmd mut Command) add_default_commands() {
|
||||
}
|
||||
}
|
||||
|
||||
fn (cmd mut Command) parse_flags() {
|
||||
fn (mut cmd Command) parse_flags() {
|
||||
for {
|
||||
if cmd.args.len < 1 || !cmd.args[0].starts_with('-') {
|
||||
break
|
||||
@ -137,7 +137,7 @@ fn (cmd &Command) parse_commands() {
|
||||
|
||||
execute := cmd.execute
|
||||
execute(cmd) // TODO: fix once higher order function can be execute on struct variable
|
||||
|
||||
|
||||
if int(cmd.post_execute) > 0 {
|
||||
post_execute := cmd.post_execute
|
||||
post_execute(cmd)
|
||||
|
Reference in New Issue
Block a user