59 lines
1.8 KiB
Go
59 lines
1.8 KiB
Go
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"github.com/spf13/cobra"
|
||
|
// "github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
|
||
|
// cfgFile string
|
||
|
// userLicense string
|
||
|
|
||
|
rootCmd = &cobra.Command {
|
||
|
Use: "kilt",
|
||
|
Short: "Kills a process after a set duration",
|
||
|
Long: "Kill a process after a set duration.\nSet a duration in seconds, followed by the binary and its parameters and arguments.",
|
||
|
}
|
||
|
)
|
||
|
|
||
|
func Execute() error {
|
||
|
return rootCmd.Execute()
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
// cobra.OnInitialize(initConfig)
|
||
|
|
||
|
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
|
||
|
// rootCmd.PersistentFlags().StringP("author", "a", "Your Name", "author for copyright attribution")
|
||
|
// rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
|
||
|
// rootCmd.PersistentFlags().Bool("viper", true, "user Viper for configuration")
|
||
|
// viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
|
||
|
// viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))
|
||
|
// viper.SetDefault("author", "Stefan Etringer stefanfriese@stefanfriese.link")
|
||
|
// viper.SetDefault("license", "Good luck with that shit!")
|
||
|
|
||
|
// rootCmd.AddCommand(versionCmd)
|
||
|
// rootCmd.AddCommand(initCmd)
|
||
|
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||
|
}
|
||
|
|
||
|
// func initConfig() {
|
||
|
// if cfgFile != "" {
|
||
|
// viper.SetConfigFile(cfgFile)
|
||
|
// }else{
|
||
|
// home, err := os.UserHomeDir()
|
||
|
// cobra.CheckErr(err)
|
||
|
|
||
|
// viper.AddConfigPath(home)
|
||
|
// viper.SetConfigType("yaml")
|
||
|
// viper.SetConfigName(".cobra")
|
||
|
// }
|
||
|
|
||
|
// viper.AutomaticEnv()
|
||
|
|
||
|
// if err := viper.ReadInConfig(); err == nil {
|
||
|
// fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||
|
// }
|
||
|
// }
|