1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/cli/version.v

26 lines
489 B
V
Raw Normal View History

2019-11-21 15:03:12 +03:00
module cli
fn version_flag(with_abbrev bool) Flag {
sabbrev := if with_abbrev { 'v' } else { '' }
2019-11-21 15:03:12 +03:00
return Flag{
flag: .bool
name: 'version'
abbrev: sabbrev
2020-08-21 00:14:53 +03:00
description: 'Prints version information.'
2019-11-21 15:03:12 +03:00
}
}
fn version_cmd() Command {
return Command{
name: 'version'
2020-08-21 00:14:53 +03:00
description: 'Prints version information.'
execute: version_func
2019-11-21 15:03:12 +03:00
}
}
fn version_func(version_cmd Command) ! {
2019-11-21 15:03:12 +03:00
cmd := version_cmd.parent
version := '${cmd.name} version ${cmd.version}'
2019-11-21 15:03:12 +03:00
println(version)
}