mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: change all '$expr' to '${expr}' (#16428)
This commit is contained in:
@ -39,29 +39,29 @@ pub mut:
|
||||
pub fn (cmd Command) str() string {
|
||||
mut res := []string{}
|
||||
res << 'Command{'
|
||||
res << ' name: "$cmd.name"'
|
||||
res << ' usage: "$cmd.usage"'
|
||||
res << ' version: "$cmd.version"'
|
||||
res << ' description: "$cmd.description"'
|
||||
res << ' man_description: "$cmd.man_description"'
|
||||
res << ' disable_help: $cmd.disable_help'
|
||||
res << ' disable_man: $cmd.disable_man'
|
||||
res << ' disable_flags: $cmd.disable_flags'
|
||||
res << ' disable_version: $cmd.disable_version'
|
||||
res << ' sort_flags: $cmd.sort_flags'
|
||||
res << ' sort_commands: $cmd.sort_commands'
|
||||
res << ' cb execute: $cmd.execute'
|
||||
res << ' cb pre_execute: $cmd.pre_execute'
|
||||
res << ' cb post_execute: $cmd.post_execute'
|
||||
res << ' name: "${cmd.name}"'
|
||||
res << ' usage: "${cmd.usage}"'
|
||||
res << ' version: "${cmd.version}"'
|
||||
res << ' description: "${cmd.description}"'
|
||||
res << ' man_description: "${cmd.man_description}"'
|
||||
res << ' disable_help: ${cmd.disable_help}'
|
||||
res << ' disable_man: ${cmd.disable_man}'
|
||||
res << ' disable_flags: ${cmd.disable_flags}'
|
||||
res << ' disable_version: ${cmd.disable_version}'
|
||||
res << ' sort_flags: ${cmd.sort_flags}'
|
||||
res << ' sort_commands: ${cmd.sort_commands}'
|
||||
res << ' cb execute: ${cmd.execute}'
|
||||
res << ' cb pre_execute: ${cmd.pre_execute}'
|
||||
res << ' cb post_execute: ${cmd.post_execute}'
|
||||
if unsafe { cmd.parent == 0 } {
|
||||
res << ' parent: &Command(0)'
|
||||
} else {
|
||||
res << ' parent: &Command{$cmd.parent.name ...}'
|
||||
res << ' parent: &Command{${cmd.parent.name} ...}'
|
||||
}
|
||||
res << ' commands: $cmd.commands'
|
||||
res << ' flags: $cmd.flags'
|
||||
res << ' required_args: $cmd.required_args'
|
||||
res << ' args: $cmd.args'
|
||||
res << ' commands: ${cmd.commands}'
|
||||
res << ' flags: ${cmd.flags}'
|
||||
res << ' required_args: ${cmd.required_args}'
|
||||
res << ' args: ${cmd.args}'
|
||||
res << '}'
|
||||
return res.join('\n')
|
||||
}
|
||||
@ -84,7 +84,7 @@ pub fn (cmd Command) full_name() string {
|
||||
if cmd.is_root() {
|
||||
return cmd.name
|
||||
}
|
||||
return cmd.parent.full_name() + ' $cmd.name'
|
||||
return cmd.parent.full_name() + ' ${cmd.name}'
|
||||
}
|
||||
|
||||
// add_commands adds the `commands` array of `Command`s as sub-commands.
|
||||
@ -98,7 +98,7 @@ pub fn (mut cmd Command) add_commands(commands []Command) {
|
||||
pub fn (mut cmd Command) add_command(command Command) {
|
||||
mut subcmd := command
|
||||
if cmd.commands.contains(subcmd.name) {
|
||||
eprintln_exit('Command with the name `$subcmd.name` already exists')
|
||||
eprintln_exit('Command with the name `${subcmd.name}` already exists')
|
||||
}
|
||||
subcmd.parent = unsafe { cmd }
|
||||
cmd.commands << subcmd
|
||||
@ -124,7 +124,7 @@ pub fn (mut cmd Command) add_flags(flags []Flag) {
|
||||
// add_flag adds `flag` to this `Command`.
|
||||
pub fn (mut cmd Command) add_flag(flag Flag) {
|
||||
if cmd.flags.contains(flag.name) {
|
||||
eprintln_exit('Flag with the name `$flag.name` already exists')
|
||||
eprintln_exit('Flag with the name `${flag.name}` already exists')
|
||||
}
|
||||
cmd.flags << flag
|
||||
}
|
||||
@ -191,14 +191,14 @@ fn (mut cmd Command) parse_flags() {
|
||||
found = true
|
||||
flag.found = true
|
||||
cmd.args = flag.parse(cmd.args, cmd.posix_mode) or {
|
||||
eprintln_exit('Failed to parse flag `${cmd.args[0]}`: $err')
|
||||
eprintln_exit('Failed to parse flag `${cmd.args[0]}`: ${err}')
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
eprintln_exit('Command `$cmd.name` has no flag `${cmd.args[0]}`')
|
||||
eprintln_exit('Command `${cmd.name}` has no flag `${cmd.args[0]}`')
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,7 +230,7 @@ fn (mut cmd Command) parse_commands() {
|
||||
// if no further command was found, execute current command
|
||||
if cmd.required_args > 0 {
|
||||
if cmd.required_args > cmd.args.len {
|
||||
eprintln_exit('Command `$cmd.name` needs at least $cmd.required_args arguments')
|
||||
eprintln_exit('Command `${cmd.name}` needs at least ${cmd.required_args} arguments')
|
||||
}
|
||||
}
|
||||
cmd.check_required_flags()
|
||||
@ -243,8 +243,8 @@ fn (mut cmd Command) parse_commands() {
|
||||
fn (mut cmd Command) handle_cb(cb FnCommandCallback, label string) {
|
||||
if !isnil(cb) {
|
||||
cb(*cmd) or {
|
||||
label_message := term.ecolorize(term.bright_red, 'cli $label error:')
|
||||
eprintln_exit('$label_message $err')
|
||||
label_message := term.ecolorize(term.bright_red, 'cli ${label} error:')
|
||||
eprintln_exit('${label_message} ${err}')
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -284,7 +284,7 @@ fn (cmd Command) check_required_flags() {
|
||||
for flag in cmd.flags {
|
||||
if flag.required && flag.value.len == 0 {
|
||||
full_name := cmd.full_name()
|
||||
eprintln_exit('Flag `$flag.name` is required by `$full_name`')
|
||||
eprintln_exit('Flag `${flag.name}` is required by `${full_name}`')
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,7 +317,7 @@ fn (cmds []Command) get(name string) !Command {
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
return error('Command `$name` not found in $cmds')
|
||||
return error('Command `${name}` not found in ${cmds}')
|
||||
}
|
||||
|
||||
fn (cmds []Command) contains(name string) bool {
|
||||
|
Reference in New Issue
Block a user