Boilerplate for all operations
This commit is contained in:
parent
9e67002b0d
commit
d597da3b64
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("archive called")
|
||||
},
|
||||
RunE: opArchive,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(archiveCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// archiveCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// archiveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opArchive(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("archive called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 brian buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("config called")
|
||||
},
|
||||
RunE: opConfig,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(configCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// configCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// configCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opConfig(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("config called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("editor called")
|
||||
},
|
||||
RunE: opEditor,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(editorCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// editorCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// editorCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opEditor(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("editor called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,40 +1,33 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.bullercodeworks.com/brian/gime/util"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// fuzzyparseCmd represents the fuzzyparse command
|
||||
var fuzzyparseCmd = &cobra.Command{
|
||||
Use: "fuzzyparse",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("fuzzyparse called")
|
||||
Short: "Fuzzy parse the given text into a RFC3339 date",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) > 0 {
|
||||
if start, err := util.ParseFuzzyTime(args[0]); err == nil {
|
||||
fmt.Println(start.Format(time.RFC3339))
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(fuzzyparseCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// fuzzyparseCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// fuzzyparseCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
|
21
cmd/mod.go
21
cmd/mod.go
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("mod called")
|
||||
},
|
||||
RunE: opMod,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(modCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// modCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// modCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opMod(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("mod called")
|
||||
return nil
|
||||
}
|
||||
|
21
cmd/rm.go
21
cmd/rm.go
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("rm called")
|
||||
},
|
||||
RunE: opRemove,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(rmCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// rmCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// rmCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opRemove(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("remove called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
|
21
cmd/start.go
21
cmd/start.go
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("start called")
|
||||
},
|
||||
RunE: opStart,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(startCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// startCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// startCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opStart(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("start called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
|
21
cmd/stop.go
21
cmd/stop.go
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("stop called")
|
||||
},
|
||||
RunE: opStop,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(stopCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// stopCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// stopCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opStop(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("stop called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("switch called")
|
||||
},
|
||||
RunE: opSwitch,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(switchCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// switchCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// switchCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opSwitch(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("switch called")
|
||||
return nil
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
|
||||
*/
|
||||
package cmd
|
||||
@ -20,21 +20,14 @@ and usage of using your command. For example:
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("toggle called")
|
||||
},
|
||||
RunE: opToggle,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(toggleCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// toggleCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// toggleCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opToggle(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("toggle called")
|
||||
return nil
|
||||
}
|
||||
|
30
cmd/ui.go
30
cmd/ui.go
@ -1,6 +1,5 @@
|
||||
/*
|
||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||
|
||||
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
||||
*/
|
||||
package cmd
|
||||
|
||||
@ -13,28 +12,15 @@ import (
|
||||
// uiCmd represents the ui command
|
||||
var uiCmd = &cobra.Command{
|
||||
Use: "ui",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("ui called")
|
||||
},
|
||||
Short: "Start gime in TUI mode",
|
||||
RunE: opUi,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(uiCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// uiCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// uiCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func opUi(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("ui called")
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user