From f65c5b9c7f341130c2e7932f3803db49ea0bf7ef Mon Sep 17 00:00:00 2001 From: Niclas van Eyk Date: Sat, 17 Jun 2023 13:04:21 +0200 Subject: [PATCH] add --plain flag to show command --- cmd/show.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/show.go b/cmd/show.go index 752f673..4228592 100644 --- a/cmd/show.go +++ b/cmd/show.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "os" clog "github.com/niclasvaneyk/keepac/internal/changelog" @@ -8,6 +9,8 @@ import ( "github.com/spf13/cobra" ) +var shouldShowPlain bool + // showCmd represents the show command var showCmd = &cobra.Command{ Use: "show", @@ -24,6 +27,11 @@ var showCmd = &cobra.Command{ return err } + if shouldShowPlain { + fmt.Print(string(source)) + return nil + } + return clog.Show(string(source)) }, } @@ -37,6 +45,8 @@ func init() { // and all subcommands, e.g.: // showCmd.PersistentFlags().String("foo", "", "A help for foo") + showCmd.Flags().BoolVarP(&shouldShowPlain, "plain", "p", false, "Only print the raw contents, without terminal decorations") + // Cobra supports local flags which will only run when this command // is called directly, e.g.: // showCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")