From cf6cdb0dba712eae55b1050b36b11f50d02e03fc Mon Sep 17 00:00:00 2001 From: Luca Grulla Date: Thu, 16 Aug 2018 16:30:43 +0100 Subject: [PATCH] Add man pages (man cw) --- .goreleaser.yml | 4 ++++ main.go | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index d782c7b0..edc55f26 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -41,5 +41,9 @@ brew: system bin/"cw --completion-script-bash > cw.bash" bash_completion.install "cw.bash" + system bin/"cw --help-man > cw.1" + man1.install "cw.1" + + # system bin/"cw completion zsh > cw.zsh" # zsh_completion.install "cw.zsh" diff --git a/main.go b/main.go index 656f6d55..86e3fd6a 100644 --- a/main.go +++ b/main.go @@ -17,12 +17,15 @@ import ( ) var ( - lsCommand = kingpin.Command("ls", "Show an entity") + version = "1.6.0" + kp = kingpin.New("cw", "The best way to tail AWS Cloudwatch Logs from your terminal.") + + lsCommand = kp.Command("ls", "Show an entity") lsGroups = lsCommand.Command("groups", "Show all groups.") lsStreams = lsCommand.Command("streams", "Show all streams in a given log group.") lsLogGroupName = lsStreams.Arg("group", "the group name").HintAction(groupsCompletion).Required().String() - tailCommand = kingpin.Command("tail", "Tail a log group.") + tailCommand = kp.Command("tail", "Tail a log group.") follow = tailCommand.Flag("follow", "Don't stop when the end of stream is reached, but rather wait for additional data to be appended.").Short('f').Default("false").Bool() printTimestamp = tailCommand.Flag("timestamp", "Print the event timestamp.").Short('t').Default("false").Bool() @@ -115,15 +118,12 @@ func versionCheckOnSigterm(version string, latestVersionChannel chan string) { } func main() { - version := "1.6.0" - kingpin.Version(version).Author("Luca Grulla") - command := kingpin.Parse() - + kp.Version(version).Author("Luca Grulla") latestVersionChannel := fetchLatestVersion() versionCheckOnSigterm(version, latestVersionChannel) - switch command { + switch kingpin.MustParse(kp.Parse(os.Args[1:])) { case "ls groups": for msg := range cloudwatch.LsGroups() { fmt.Println(*msg)