Skip to content

Commit

Permalink
add --plain flag to show command
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasvanEyk committed Jun 17, 2023
1 parent 2c466e4 commit f65c5b9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/show.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package cmd

import (
"fmt"
"os"

clog "github.com/niclasvaneyk/keepac/internal/changelog"

"github.com/spf13/cobra"
)

var shouldShowPlain bool

// showCmd represents the show command
var showCmd = &cobra.Command{
Use: "show",
Expand All @@ -24,6 +27,11 @@ var showCmd = &cobra.Command{
return err
}

if shouldShowPlain {
fmt.Print(string(source))
return nil
}

return clog.Show(string(source))
},
}
Expand All @@ -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")
Expand Down

0 comments on commit f65c5b9

Please sign in to comment.