cmd/v: version: print only main repo hash

pull/4923/head
Alexander Medvednikov 2020-05-16 23:52:03 +02:00
parent fb27fe5379
commit 81148fa2bd
2 changed files with 18 additions and 10 deletions

View File

@ -37,18 +37,18 @@ fn main_v() {
util.launch_tool(false, 'vrepl')
return
}
args_and_flags := util.join_env_vflags_and_os_args()[1..]
prefs, command := pref.parse_args(args_and_flags)
//if prefs.is_verbose {
//println('command = "$command"')
//println(util.full_v_version(prefs.is_verbose))
//}
if args.len > 0 && (args[0] in ['version', '-V', '-version', '--version'] || (args[0] ==
'-v' && args.len == 1)) {
// `-v` flag is for setting verbosity, but without any args it prints the version, like Clang
println(util.full_v_version())
println(util.full_v_version(prefs.is_verbose))
return
}
args_and_flags := util.join_env_vflags_and_os_args()[1..]
prefs, command := pref.parse_args(args_and_flags)
if prefs.is_verbose {
println('command = "$command"')
println(util.full_v_version())
}
if prefs.is_verbose {
// println('args= ')
// println(args) // QTODO
@ -82,6 +82,10 @@ fn main_v() {
println('V Error: Use `v install` to install modules from vpm.vlang.io')
exit(1)
}
'version' {
println(util.full_v_version(prefs.is_verbose))
return
}
'symlink' {
create_symlink()
return

View File

@ -33,8 +33,12 @@ pub fn full_hash() string {
}
// full_v_version() returns the full version of the V compiler
pub fn full_v_version() string {
return 'V ${v_version} ${full_hash()}'
pub fn full_v_version(is_verbose bool) string {
if is_verbose {
return 'V ${v_version} ${full_hash()}'
}
hash := githash(false)
return 'V ${v_version} $hash'
}
// githash(x) returns the current git commit hash.
@ -172,7 +176,7 @@ pub fn quote_path_with_spaces(s string) string {
pub fn args_quote_paths_with_spaces(args []string) string {
mut res := []string{}
for a in args {
res << quote_path_with_spaces( a )
res << quote_path_with_spaces(a)
}
return res.join(' ')
}