1
0
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:
yuyi
2020-05-17 19:51:18 +08:00
committed by GitHub
parent b138cadbcb
commit 7f4cf08516
87 changed files with 492 additions and 480 deletions

View File

@ -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)