1
0
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:
yuyi
2022-11-15 21:53:13 +08:00
committed by GitHub
parent 56239b4a23
commit 017ace6ea7
859 changed files with 7156 additions and 7135 deletions

View File

@ -8,9 +8,9 @@ const vroot = @VMODROOT
fn get_vdoctor_output(is_verbose bool) string {
vexe := os.getenv('VEXE')
verbose_flag := if is_verbose { '-v' } else { '' }
result := os.execute('${os.quoted_path(vexe)} $verbose_flag doctor')
result := os.execute('${os.quoted_path(vexe)} ${verbose_flag} doctor')
if result.exit_code != 0 {
eprintln('unable to get `v doctor` output: $result.output')
eprintln('unable to get `v doctor` output: ${result.output}')
return ''
}
return result.output
@ -23,21 +23,21 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
wd := os.getwd()
os.chdir(vroot) or {}
verbose_flag := if is_verbose { '-v' } else { '' }
vdbg_path := $if windows { '$vroot/vdbg.exe' } $else { '$vroot/vdbg' }
vdbg_compilation_cmd := '${os.quoted_path(vexe)} $verbose_flag -g -o ${os.quoted_path(vdbg_path)} cmd/v'
vdbg_path := $if windows { '${vroot}/vdbg.exe' } $else { '${vroot}/vdbg' }
vdbg_compilation_cmd := '${os.quoted_path(vexe)} ${verbose_flag} -g -o ${os.quoted_path(vdbg_path)} cmd/v'
vdbg_result := os.execute(vdbg_compilation_cmd)
os.chdir(wd) or {}
if vdbg_result.exit_code == 0 {
vexe = vdbg_path
} else {
eprintln('unable to compile V in debug mode: $vdbg_result.output\ncommand: $vdbg_compilation_cmd\n')
eprintln('unable to compile V in debug mode: ${vdbg_result.output}\ncommand: ${vdbg_compilation_cmd}\n')
}
//
mut result := os.execute('${os.quoted_path(vexe)} $verbose_flag ${os.quoted_path(file_path)}')
mut result := os.execute('${os.quoted_path(vexe)} ${verbose_flag} ${os.quoted_path(file_path)}')
defer {
os.rm(vdbg_path) or {
if is_verbose {
eprintln('unable to delete `vdbg`: $err')
eprintln('unable to delete `vdbg`: ${err}')
}
}
}
@ -49,14 +49,14 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
}
os.rm(generated_file) or {
if is_verbose {
eprintln('unable to delete generated file: $err')
eprintln('unable to delete generated file: ${err}')
}
}
}
run := is_yes
|| ask('It looks like the compilation went well, do you want to run the file?')
if run {
result = os.execute('${os.quoted_path(vexe)} $verbose_flag run ${os.quoted_path(file_path)}')
result = os.execute('${os.quoted_path(vexe)} ${verbose_flag} run ${os.quoted_path(file_path)}')
if result.exit_code == 0 && !is_yes {
confirm_or_exit('It looks like the file ran correctly as well, are you sure you want to continue?')
}
@ -66,7 +66,7 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
}
fn ask(msg string) bool {
prompt := os.input_opt('$msg [Y/n] ') or { 'y' }
prompt := os.input_opt('${msg} [Y/n] ') or { 'y' }
return prompt == '' || prompt[0].ascii_str().to_lower() != 'n'
}
@ -90,7 +90,7 @@ fn main() {
}
else {
if !arg.ends_with('.v') && !arg.ends_with('.vsh') && !arg.ends_with('.vv') {
eprintln('unknown argument: `$arg`')
eprintln('unknown argument: `${arg}`')
exit(1)
}
if file_path != '' {
@ -111,7 +111,7 @@ fn main() {
vdoctor_output := get_vdoctor_output(is_verbose)
// file content
file_content := os.read_file(file_path) or {
eprintln('unable to get file "$file_path" content: $err')
eprintln('unable to get file "${file_path}" content: ${err}')
''
}
// output from `v -g -o vdbg cmd/v && vdbg file.v`
@ -136,26 +136,26 @@ fn main() {
raw_body := '<!-- It is advisable to update all relevant modules using `v outdated` and `v install` -->
**V doctor:**
```
$vdoctor_output
${vdoctor_output}
```
**What did you do?**
`v -g -o vdbg cmd/v && vdbg $file_path`
`v -g -o vdbg cmd/v && vdbg ${file_path}`
{file_content}
**What did you expect to see?**
$expected_result
${expected_result}
**What did you see instead?**
```
$build_output```'
mut encoded_body := urllib.query_escape(raw_body.replace_once('{file_content}', '```v\n$file_content\n```'))
mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
${build_output}```'
mut encoded_body := urllib.query_escape(raw_body.replace_once('{file_content}', '```v\n${file_content}\n```'))
mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=${encoded_body}'
if generated_uri.len > 8192 {
// GitHub doesn't support URLs longer than 8192 characters
encoded_body = urllib.query_escape(raw_body.replace_once('{file_content}', 'See attached file `$file_path`'))
generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
encoded_body = urllib.query_escape(raw_body.replace_once('{file_content}', 'See attached file `${file_path}`'))
generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=${encoded_body}'
println('Your file is too big to be submitted. Head over to the following URL and attach your file.')
println(generated_uri)
} else {