From 635457fe01cf9fa42d1424aaceed17191e7fcac0 Mon Sep 17 00:00:00 2001 From: Matt McQuillan Date: Fri, 15 Dec 2017 09:32:01 -0500 Subject: [PATCH] adding a version, because why not --- config/validate.go | 2 +- fetch/help.go | 4 +++- fetch/version.go | 14 ++++++++++++++ lawsg.go | 6 +++++- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 fetch/version.go 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) } }