mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cli: update mutability
This commit is contained in:
parent
c8d111924d
commit
bf1b751f47
@ -79,7 +79,7 @@ fn (cmd mut Command) parse_flags() {
|
||||
mut flag := &cmd.flags[i]
|
||||
if flag.matches(cmd.args) {
|
||||
found = true
|
||||
mut args := flag.parse(cmd.args) or { // TODO: fix once options types can be assigned to struct variables
|
||||
args := flag.parse(cmd.args) or { // TODO: fix once options types can be assigned to struct variables
|
||||
println('failed to parse flag ${cmd.args[0]}: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
@ -95,7 +95,7 @@ fn (cmd mut Command) parse_flags() {
|
||||
}
|
||||
}
|
||||
|
||||
fn (cmd mut Command) parse_commands() {
|
||||
fn (cmd &Command) parse_commands() {
|
||||
flags := cmd.flags
|
||||
global_flags := flags.filter(it.global) // TODO: fix once filter can be applied to struct variable
|
||||
|
||||
@ -131,7 +131,7 @@ fn (cmd mut Command) parse_commands() {
|
||||
}
|
||||
}
|
||||
|
||||
fn (cmd mut Command) check_help_flag() {
|
||||
fn (cmd &Command) check_help_flag() {
|
||||
if cmd.disable_help {
|
||||
return
|
||||
}
|
||||
@ -146,7 +146,7 @@ fn (cmd mut Command) check_help_flag() {
|
||||
}
|
||||
}
|
||||
|
||||
fn (cmd mut Command) check_version_flag() {
|
||||
fn (cmd &Command) check_version_flag() {
|
||||
if cmd.disable_version {
|
||||
return
|
||||
}
|
||||
@ -161,7 +161,7 @@ fn (cmd mut Command) check_version_flag() {
|
||||
}
|
||||
}
|
||||
|
||||
fn (cmd mut Command) check_required_flags() {
|
||||
fn (cmd &Command) check_required_flags() {
|
||||
for flag in cmd.flags {
|
||||
if flag.required && flag.value == '' {
|
||||
full_name := cmd.full_name()
|
||||
|
@ -59,7 +59,7 @@ fn (flag mut Flag) parse(args []string) ?[]string {
|
||||
}
|
||||
|
||||
// check if first arg matches flag
|
||||
fn (flag mut Flag) matches(args []string) bool {
|
||||
fn (flag &Flag) matches(args []string) bool {
|
||||
return
|
||||
(flag.name != '' && args[0].starts_with('--${flag.name}')) ||
|
||||
(flag.abbrev != '' && args[0].starts_with('-${flag.abbrev}'))
|
||||
|
Loading…
Reference in New Issue
Block a user