Skip to content

Commit 875ceb7

Browse files
committed
Addded version
1 parent a8b697b commit 875ceb7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cli.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ type Option struct {
3838

3939
type EnsCli struct {
4040
name string
41+
version string
4142
log logger.Logger
4243
funcs map[string]*Function
4344
options []*Option
4445
}
4546

4647
func NewEnsCli(name string, log logger.Logger) (*EnsCli, error) {
47-
return &EnsCli{name: name, log: log, funcs: make(map[string]*Function), options: make([]*Option, 0)}, nil
48+
return &EnsCli{name: name, version: "0.0.1", log: log, funcs: make(map[string]*Function), options: make([]*Option, 0)}, nil
49+
}
50+
51+
func (cli *EnsCli) SetVersion(version string) {
52+
cli.version = version
4853
}
4954

5055
func (cli *EnsCli) AddCommand(cmd string, f *Function) {
@@ -85,6 +90,9 @@ func (cli *EnsCli) Run() {
8590
cli.showHelp()
8691
return
8792
}
93+
if cmd == "-v" {
94+
cli.log.Info("Tool version : " + cli.version)
95+
}
8896
f, ok := cli.funcs[cmd]
8997
if !ok {
9098
cli.log.Error("Unsupported command, please check the helper")
@@ -182,7 +190,7 @@ func (cli *EnsCli) Run() {
182190
}
183191
}
184192
flag.Parse()
185-
cli.log.Info("Executing the function : " + f.Title)
193+
cli.log.Info("Executing the command : " + f.Title)
186194
if !f.Handler() {
187195
cli.log.Error(f.FailureMsg)
188196
} else {

0 commit comments

Comments
 (0)