Skip to content

Commit 493860d

Browse files
committed
Add posts command
1 parent aa38d6e commit 493860d

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

cmd/posts.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// postsCmd represents the posts command
10+
var postsCmd = &cobra.Command{
11+
Use: "posts",
12+
Short: "Lists posts",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
fmt.Println("posts called")
15+
},
16+
}
17+
18+
func init() {
19+
rootCmd.AddCommand(postsCmd)
20+
}

cmd/root.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ func Execute() {
2929
func init() {
3030
cobra.OnInitialize(initConfig)
3131

32-
// Here you will define your flags and configuration settings.
33-
// Cobra supports persistent flags, which, if defined here,
34-
// will be global for your application.
3532
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.hashnode.yaml)")
36-
37-
// Cobra also supports local flags, which will only run
38-
// when this action is called directly.
39-
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4033
}
4134

4235
// initConfig reads in config file and ENV variables if set.

0 commit comments

Comments
 (0)