diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index faa09aeba3..717798b81f 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -115,7 +115,7 @@ fn repl_help() { fn run_repl(workdir string, vrepl_prefix string) { if !is_stdin_a_pipe { println(util.full_v_version(false)) - println('Use Ctrl-C or `exit` to exit, or `help` to see other available commands') + println('Use Ctrl-C or ${util.pretty_print('exit')} to exit, or ${util.pretty_print('help')} to see other available commands') } if vstartup != '' { diff --git a/cmd/v/v.v b/cmd/v/v.v index b0228b09a1..a61b762bb6 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -60,9 +60,13 @@ fn main() { // Running `./v` without args launches repl if args.len == 0 { if os.is_atty(0) != 0 { - println('Welcome to the V REPL (for help with V itself, type `exit`, then run `v help`).') + cmd_exit := util.pretty_print('exit') + cmd_help := util.pretty_print('v help') + file_main := util.pretty_print('main.v') + cmd_run := util.pretty_print('v run main.v') + println('Welcome to the V REPL (for help with V itself, type $cmd_exit, then run $cmd_help).') eprintln(' NB: the REPL is highly experimental. For best V experience, use a text editor,') - eprintln(' save your code in a `main.v` file and do: `v run main.v`') + eprintln(' save your code in a $file_main file and execute: $cmd_run') } else { mut args_and_flags := util.join_env_vflags_and_os_args()[1..].clone() args_and_flags << ['run', '-'] @@ -124,7 +128,7 @@ fn main() { if prefs.is_help { invoke_help_and_exit(args) } - eprintln('v $command: unknown command\nRun "v help" for usage.') + eprintln('v $command: unknown command\nRun ${util.pretty_print('v help')} for usage.') exit(1) } @@ -134,7 +138,7 @@ fn invoke_help_and_exit(remaining []string) { 2 { help.print_and_exit(remaining[1]) } else {} } - println('`v help`: provide only one help topic.') - println('For usage information, use `v help`.') + println('${util.pretty_print('v help')}: provide only one help topic.') + println('For usage information, use ${util.pretty_print('v help')}.') exit(1) } diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index 17c43a9f60..c983a2e16b 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -5,6 +5,7 @@ module util import os import time +import term import v.pref import v.vmod import v.util.recompilation @@ -569,3 +570,9 @@ pub fn find_all_v_files(roots []string) ?[]string { } return files } + +// Highlight a command with an on-brand background to make CLI +// commands immediately recognizable. +pub fn pretty_print(command string) string { + return term.bright_white(term.bg_cyan(' $command ')) +}