From 1352d9d3ed9a10d3c78f86b77713dd02a4da1ab0 Mon Sep 17 00:00:00 2001 From: Mike Christof Date: Fri, 24 Jul 2020 15:21:01 +0100 Subject: [PATCH] feature lower and upper case --- cmd/lower.go | 29 +++++++++++++++++++++++++++++ cmd/upper.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 cmd/lower.go create mode 100644 cmd/upper.go diff --git a/cmd/lower.go b/cmd/lower.go new file mode 100644 index 0000000..410828d --- /dev/null +++ b/cmd/lower.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/spf13/cobra" +) + +var ( + lowerCmd = &cobra.Command{ + Use: "lower", + Short: "Convert to lower case", + Run: func(cmd *cobra.Command, args []string) { + Verbose(cmd) + data, err := ioutil.ReadAll(os.Stdin) + if err != nil { + panic(err) + } + fmt.Println(strings.ToLower(string(data))) + }, + } +) + +func init() { + rootCmd.AddCommand(lowerCmd) +} diff --git a/cmd/upper.go b/cmd/upper.go new file mode 100644 index 0000000..4594a61 --- /dev/null +++ b/cmd/upper.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/spf13/cobra" +) + +var ( + upperCmd = &cobra.Command{ + Use: "upper", + Short: "Convert to UPPER case", + Run: func(cmd *cobra.Command, args []string) { + Verbose(cmd) + data, err := ioutil.ReadAll(os.Stdin) + if err != nil { + panic(err) + } + fmt.Println(strings.ToUpper(string(data))) + }, + } +) + +func init() { + rootCmd.AddCommand(upperCmd) +}