M cmd/add.go => cmd/add.go +0 -2
@@ 65,8 65,6 @@ bookmarks.`,
func init() {
rootCmd.AddCommand(addCmd)
-
- addCmd.Flags().StringArrayVarP(&tags, "tag", "t", nil, "tag the bookmark")
}
func isValidURL(str string) bool {
M cmd/list.go => cmd/list.go +0 -5
@@ 23,8 23,6 @@ import (
"github.com/spf13/cobra"
)
-var plain bool
-
var listCmd = &cobra.Command{
Use: "list",
Aliases: []string{"l", "ls"},
@@ 52,7 50,4 @@ description. Bookmarks will be filtered by the tags and/or description.`,
func init() {
rootCmd.AddCommand(listCmd)
-
- listCmd.Flags().StringArrayVarP(&tags, "tag", "t", nil, "list bookmarks matching the tag")
- listCmd.Flags().BoolVarP(&plain, "plain", "p", false, "print a list of URLs instead of a table")
}
M cmd/open.go => cmd/open.go +0 -2
@@ 75,6 75,4 @@ file.`,
func init() {
rootCmd.AddCommand(openCmd)
-
- openCmd.Flags().StringArrayVarP(&tags, "tag", "t", nil, "open bookmarks matching the tag")
}
M cmd/remove.go => cmd/remove.go +0 -4
@@ 26,8 26,6 @@ import (
"github.com/spf13/cobra"
)
-var noConfirm bool
-
var removeCmd = &cobra.Command{
Use: "remove",
Aliases: []string{"r", "rm"},
@@ 86,6 84,4 @@ index values from the list command.`,
func init() {
rootCmd.AddCommand(removeCmd)
-
- removeCmd.Flags().BoolVarP(&noConfirm, "no-confirm", "n", false, "don't ask to confirm deletion")
}
M cmd/root.go => cmd/root.go +18 -5
@@ 26,11 26,20 @@ import (
"github.com/spf13/viper"
)
-var config *cfg.Config
-var cfgFile string
-var tags []string
-var indices []int
-var verbose bool
+// config
+var (
+ config *cfg.Config
+ cfgFile string
+)
+
+// options
+var (
+ tags []string
+ indices []int
+ verbose bool
+ plain bool
+ noConfirm bool
+)
var rootCmd = &cobra.Command{
Use: "bmk",
@@ 38,6 47,7 @@ var rootCmd = &cobra.Command{
Long: `bmk is a command-line bookmark manager, designed to store and retrieve bookmarks
without relying on a web-browser.
`,
+ TraverseChildren: true,
RunE: func(cmd *cobra.Command, args []string) error {
return listCmd.RunE(cmd, args)
},
@@ 57,6 67,9 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.config/bmk/config.yml)")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "print verbose messages")
+ rootCmd.PersistentFlags().BoolVarP(&noConfirm, "no-confirm", "n", false, "don't ask to confirm operations")
+ rootCmd.PersistentFlags().StringArrayVarP(&tags, "tag", "t", nil, "bookmark tags")
+ rootCmd.PersistentFlags().BoolVarP(&plain, "plain", "p", false, "print a list of URLs instead of a table")
}
func initConfig() {