Boilerplate for all operations

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

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opArchive,
fmt.Println("archive called")
},
} }
func init() { func init() {
rootCmd.AddCommand(archiveCmd) rootCmd.AddCommand(archiveCmd)
}
// Here you will define your flags and configuration settings.
func opArchive(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("archive called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 brian buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opConfig,
fmt.Println("config called")
},
} }
func init() { func init() {
rootCmd.AddCommand(configCmd) rootCmd.AddCommand(configCmd)
}
// Here you will define your flags and configuration settings.
func opConfig(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("config called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opEditor,
fmt.Println("editor called")
},
} }
func init() { func init() {
rootCmd.AddCommand(editorCmd) rootCmd.AddCommand(editorCmd)
}
// Here you will define your flags and configuration settings.
func opEditor(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("editor called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,40 +1,33 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
import ( import (
"fmt" "fmt"
"time"
"git.bullercodeworks.com/brian/gime/util"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// fuzzyparseCmd represents the fuzzyparse command // fuzzyparseCmd represents the fuzzyparse command
var fuzzyparseCmd = &cobra.Command{ var fuzzyparseCmd = &cobra.Command{
Use: "fuzzyparse", Use: "fuzzyparse",
Short: "A brief description of your command", Short: "Fuzzy parse the given text into a RFC3339 date",
Long: `A longer description that spans multiple lines and likely contains examples RunE: func(cmd *cobra.Command, args []string) error {
and usage of using your command. For example: if len(args) > 0 {
if start, err := util.ParseFuzzyTime(args[0]); err == nil {
Cobra is a CLI library for Go that empowers applications. fmt.Println(start.Format(time.RFC3339))
This application is a tool to generate the needed files } else {
to quickly create a Cobra application.`, return err
Run: func(cmd *cobra.Command, args []string) { }
fmt.Println("fuzzyparse called") }
return nil
}, },
} }
func init() { func init() {
rootCmd.AddCommand(fuzzyparseCmd) 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opMod,
fmt.Println("mod called")
},
} }
func init() { func init() {
rootCmd.AddCommand(modCmd) rootCmd.AddCommand(modCmd)
}
// Here you will define your flags and configuration settings.
func opMod(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("mod called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opRemove,
fmt.Println("rm called")
},
} }
func init() { func init() {
rootCmd.AddCommand(rmCmd) rootCmd.AddCommand(rmCmd)
}
// Here you will define your flags and configuration settings.
func opRemove(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("remove called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opStart,
fmt.Println("start called")
},
} }
func init() { func init() {
rootCmd.AddCommand(startCmd) rootCmd.AddCommand(startCmd)
}
// Here you will define your flags and configuration settings.
func opStart(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("start called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opStop,
fmt.Println("stop called")
},
} }
func init() { func init() {
rootCmd.AddCommand(stopCmd) rootCmd.AddCommand(stopCmd)
}
// Here you will define your flags and configuration settings.
func opStop(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("stop called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opSwitch,
fmt.Println("switch called")
},
} }
func init() { func init() {
rootCmd.AddCommand(switchCmd) rootCmd.AddCommand(switchCmd)
}
// Here you will define your flags and configuration settings.
func opSwitch(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("switch called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd

View File

@ -1,5 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -20,21 +20,14 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: opToggle,
fmt.Println("toggle called")
},
} }
func init() { func init() {
rootCmd.AddCommand(toggleCmd) rootCmd.AddCommand(toggleCmd)
}
// Here you will define your flags and configuration settings.
func opToggle(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("toggle called")
// and all subcommands, e.g.: return nil
// 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")
} }

View File

@ -1,6 +1,5 @@
/* /*
Copyright © 2022 NAME HERE <EMAIL ADDRESS> Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
*/ */
package cmd package cmd
@ -13,28 +12,15 @@ import (
// uiCmd represents the ui command // uiCmd represents the ui command
var uiCmd = &cobra.Command{ var uiCmd = &cobra.Command{
Use: "ui", Use: "ui",
Short: "A brief description of your command", Short: "Start gime in TUI mode",
Long: `A longer description that spans multiple lines and likely contains examples RunE: opUi,
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")
},
} }
func init() { func init() {
rootCmd.AddCommand(uiCmd) rootCmd.AddCommand(uiCmd)
}
// Here you will define your flags and configuration settings.
func opUi(cmd *cobra.Command, args []string) error {
// Cobra supports Persistent Flags which will work for this command fmt.Println("ui called")
// and all subcommands, e.g.: return nil
// 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")
} }