Skip to content

Commit 1352d9d

Browse files
committed
feature lower and upper case
1 parent 2da6649 commit 1352d9d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

cmd/lower.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"os"
7+
"strings"
8+
9+
"github.com/spf13/cobra"
10+
)
11+
12+
var (
13+
lowerCmd = &cobra.Command{
14+
Use: "lower",
15+
Short: "Convert to lower case",
16+
Run: func(cmd *cobra.Command, args []string) {
17+
Verbose(cmd)
18+
data, err := ioutil.ReadAll(os.Stdin)
19+
if err != nil {
20+
panic(err)
21+
}
22+
fmt.Println(strings.ToLower(string(data)))
23+
},
24+
}
25+
)
26+
27+
func init() {
28+
rootCmd.AddCommand(lowerCmd)
29+
}

cmd/upper.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"os"
7+
"strings"
8+
9+
"github.com/spf13/cobra"
10+
)
11+
12+
var (
13+
upperCmd = &cobra.Command{
14+
Use: "upper",
15+
Short: "Convert to UPPER case",
16+
Run: func(cmd *cobra.Command, args []string) {
17+
Verbose(cmd)
18+
data, err := ioutil.ReadAll(os.Stdin)
19+
if err != nil {
20+
panic(err)
21+
}
22+
fmt.Println(strings.ToUpper(string(data)))
23+
},
24+
}
25+
)
26+
27+
func init() {
28+
rootCmd.AddCommand(upperCmd)
29+
}

0 commit comments

Comments
 (0)