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 {
|
2019-11-21 15:03:12 +03:00
|
|
|
return Flag{
|
|
|
|
flag: .bool,
|
|
|
|
name: 'version',
|
2020-07-01 11:54:34 +03:00
|
|
|
abbrev: if with_abbrev { 'v' } else { '' },
|
2019-11-21 15:03:12 +03:00
|
|
|
description: 'Prints version information',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn version_cmd() Command {
|
|
|
|
return Command{
|
|
|
|
name: 'version'
|
|
|
|
description: 'Prints version information',
|
|
|
|
execute: version_func,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 17:04:53 +03:00
|
|
|
fn version_func(version_cmd Command) {
|
2019-11-21 15:03:12 +03:00
|
|
|
cmd := version_cmd.parent
|
|
|
|
version := '${cmd.name} v${cmd.version}'
|
|
|
|
println(version)
|
|
|
|
}
|