2019-11-21 15:03:12 +03:00
|
|
|
module cli
|
|
|
|
|
2020-07-01 11:54:34 +03:00
|
|
|
fn version_flag(with_abbrev bool) Flag {
|
2020-07-18 14:24:10 +03:00
|
|
|
sabbrev := if with_abbrev { 'v' } else { '' }
|
2019-11-21 15:03:12 +03:00
|
|
|
return Flag{
|
2020-07-18 14:24:10 +03:00
|
|
|
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.'
|
2020-07-18 14:24:10 +03:00
|
|
|
execute: version_func
|
2019-11-21 15:03:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-20 22:14:33 +03:00
|
|
|
fn version_func(version_cmd Command) ! {
|
2019-11-21 15:03:12 +03:00
|
|
|
cmd := version_cmd.parent
|
2022-11-15 16:53:13 +03:00
|
|
|
version := '${cmd.name} version ${cmd.version}'
|
2019-11-21 15:03:12 +03:00
|
|
|
println(version)
|
|
|
|
}
|