diff --git a/config/validate.go b/config/validate.go index f93f303..121a68a 100644 --- a/config/validate.go +++ b/config/validate.go @@ -20,7 +20,7 @@ func Validate(options *Options) { } // validate command - if !util.Member(options.Command, "get,groups,streams,help") { + if !util.Member(options.Command, "get,groups,streams,version,help") { options.Command = "help" options.Group = "" } diff --git a/fetch/help.go b/fetch/help.go index 5fdf98b..b85dfe2 100644 --- a/fetch/help.go +++ b/fetch/help.go @@ -9,7 +9,7 @@ import ( ) // Help - display the help -func Help(options config.Options) { +func Help(options config.Options, version string) { if options.Group == "" { options.Group = "less" @@ -30,6 +30,7 @@ func Help(options config.Options) { fmt.Println(" lawsg groups [options]") fmt.Println(" lawsg streams [options]") fmt.Println(" lawsg get [options]") + fmt.Println(" lawsg version") fmt.Println("") } @@ -198,6 +199,7 @@ func Help(options config.Options) { if util.Member(options.Group, "about,more,docs") { fmt.Println("ABOUT:") + fmt.Println(" lawsg", version) fmt.Println(" Free to Use and Contribute via the MIT License") fmt.Println(" Maintained by Matt McQuillan") fmt.Println(" https://github.com/mmcquillan/lawsg") diff --git a/fetch/version.go b/fetch/version.go new file mode 100644 index 0000000..bffd032 --- /dev/null +++ b/fetch/version.go @@ -0,0 +1,14 @@ +package fetch + +import ( + "fmt" +) + +func Version(version string) { + if version == "" { + version = "(compiled)" + } + fmt.Println("") + fmt.Println("lawsg", version) + fmt.Println("") +} diff --git a/lawsg.go b/lawsg.go index d1ff93c..79b200f 100644 --- a/lawsg.go +++ b/lawsg.go @@ -5,6 +5,8 @@ import ( "github.com/mmcquillan/lawsg/fetch" ) +var version string + func main() { config.Aws() var options config.Options @@ -21,7 +23,9 @@ func main() { fetch.Streams(options) case "get": fetch.Logs(options) + case "version": + fetch.Version(version) default: - fetch.Help(options) + fetch.Help(options, version) } }