mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: enhance version with current git commit hash. Cleanup redundant code.
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
term
|
||||
readline
|
||||
os.cmdline
|
||||
v.util
|
||||
)
|
||||
|
||||
struct Repl {
|
||||
@ -63,8 +64,7 @@ fn (r &Repl) function_call(line string) bool {
|
||||
}
|
||||
|
||||
pub fn repl_help() {
|
||||
version := v_version()
|
||||
println(version)
|
||||
println(util.full_v_version())
|
||||
println('
|
||||
help Displays this information.
|
||||
Ctrl-C, Ctrl-D, exit Exits the REPL.
|
||||
@ -73,8 +73,7 @@ pub fn repl_help() {
|
||||
}
|
||||
|
||||
pub fn run_repl(workdir string, vrepl_prefix string) []string {
|
||||
version := v_version()
|
||||
println(version)
|
||||
println(util.full_v_version())
|
||||
println('Use Ctrl-C or `exit` to exit')
|
||||
|
||||
file := os.join_path(workdir, '.${vrepl_prefix}vrepl.v')
|
||||
@ -233,9 +232,3 @@ pub fn rerror(s string) {
|
||||
os.flush()
|
||||
exit(1)
|
||||
}
|
||||
|
||||
fn v_version() string {
|
||||
vexe := os.getenv('VEXE')
|
||||
vversion_res := os.exec('$vexe -version') or { panic('"$vexe -version" is not working') }
|
||||
return vversion_res.output
|
||||
}
|
||||
|
@ -7,16 +7,12 @@ import (
|
||||
os
|
||||
time
|
||||
v.pref
|
||||
v.util
|
||||
term
|
||||
)
|
||||
|
||||
pub const (
|
||||
v_version = '0.1.26'
|
||||
)
|
||||
|
||||
|
||||
const (
|
||||
v_modules_path = pref.default_module_path
|
||||
v_modules_path = pref.default_module_path
|
||||
)
|
||||
|
||||
fn todo() {
|
||||
@ -380,7 +376,7 @@ start:
|
||||
==================
|
||||
C error. This should never happen.
|
||||
|
||||
V compiler version: V $v_version $vhash()
|
||||
V compiler version: ${util.full_v_version()}
|
||||
Host OS: ${pref.get_host_os().str()}
|
||||
Target OS: $v.pref.os.str()
|
||||
|
||||
@ -626,11 +622,3 @@ fn error_context_lines(text, keyword string, before, after int) []string {
|
||||
idx_e := if idx_s + after < lines.len { idx_s + after } else { lines.len }
|
||||
return lines[idx_s..idx_e]
|
||||
}
|
||||
|
||||
fn vhash() string {
|
||||
mut buf := [50]byte
|
||||
buf[0] = 0
|
||||
C.snprintf(charptr(buf), 50, '%s', C.V_COMMIT_HASH)
|
||||
return tos_clone(buf)
|
||||
}
|
||||
|
||||
|
18
cmd/v/v.v
18
cmd/v/v.v
@ -11,6 +11,7 @@ import (
|
||||
v.table
|
||||
v.doc
|
||||
v.pref
|
||||
v.util
|
||||
)
|
||||
|
||||
const (
|
||||
@ -23,11 +24,6 @@ const (
|
||||
'setup-freetype']
|
||||
)
|
||||
|
||||
pub const (
|
||||
v_version = '0.1.26'
|
||||
)
|
||||
|
||||
|
||||
fn main() {
|
||||
prefs := flag.MainCmdPreferences{}
|
||||
values := flag.parse_main_cmd(os.args, parse_flags, prefs) or {
|
||||
@ -36,7 +32,7 @@ fn main() {
|
||||
exit(1)
|
||||
}
|
||||
if prefs.verbosity.is_higher_or_equal(.level_two) {
|
||||
println('V $v_version $vhash()')
|
||||
println(util.full_v_version())
|
||||
}
|
||||
if prefs.verbosity.is_higher_or_equal(.level_three) {
|
||||
println('Parsed preferences: ')
|
||||
@ -126,18 +122,10 @@ fn main() {
|
||||
}
|
||||
|
||||
fn print_version_and_exit() {
|
||||
version_hash := vhash()
|
||||
println('V $v_version $version_hash')
|
||||
println(util.full_v_version())
|
||||
exit(0)
|
||||
}
|
||||
|
||||
fn vhash() string {
|
||||
mut buf := [50]byte
|
||||
buf[0] = 0
|
||||
C.snprintf(charptr(buf), 50, '%s', C.V_COMMIT_HASH)
|
||||
return tos_clone(buf)
|
||||
}
|
||||
|
||||
fn invoke_help_and_exit(remaining []string) {
|
||||
match remaining.len {
|
||||
0, 1 {
|
||||
|
Reference in New Issue
Block a user