gime/cmd/fuzzyparse.go

34 lines
633 B
Go

/*
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: "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)
}