Boilerplate for all operations

This commit is contained in:
2022-01-19 15:30:30 -06:00
parent 9e67002b0d
commit d597da3b64
16 changed files with 89 additions and 173 deletions

View File

@@ -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")
}