Skip to content

Commit

Permalink
feature lower and upper case
Browse files Browse the repository at this point in the history
  • Loading branch information
mhristof committed Jul 24, 2020
1 parent 2da6649 commit 1352d9d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cmd/lower.go
Original file line number Diff line number Diff line change
@@ -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)
}
29 changes: 29 additions & 0 deletions cmd/upper.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 1352d9d

Please sign in to comment.