From 2270cb88b85c2a36aa60abc820b2dd18e73833e1 Mon Sep 17 00:00:00 2001 From: Paulson McIntyre Date: Thu, 28 Apr 2022 14:16:09 -0400 Subject: [PATCH] Skel init --- .gitignore | 5 ++++ LICENSE | 14 ++++----- Procfile | 2 ++ cmd/root.go | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 3 ++ main.go | 23 ++++++++++++++ 6 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 Procfile create mode 100644 cmd/root.go create mode 100644 go.mod create mode 100644 main.go diff --git a/.gitignore b/.gitignore index 66fd13c..bac6980 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,8 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# Jetbrains +.idea/ +*.iml + diff --git a/LICENSE b/LICENSE index f288702..1840fd9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -653,22 +653,22 @@ Also add information on how to contact you by electronic and paper mail. notice like this when it starts in an interactive mode: Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. + under certain conditions; type 'show c' for details. -The hypothetical commands `show w' and `show c' should show the appropriate +The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..ed6c4a8 --- /dev/null +++ b/Procfile @@ -0,0 +1,2 @@ +web: main web +release: main release diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..5028d30 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,86 @@ +/* +Copyright © 2022 Paulson McIntyre + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" + "os" + + homedir "github.com/mitchellh/go-homedir" + "github.com/spf13/viper" +) + +var cfgFile string + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "fragevents", + Short: "A brief description of your application", + Long: `A longer description that spans multiple lines and likely contains +examples and usage of using your application. 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.`, + // Uncomment the following line if your bare application + // has an action associated with it: + // Run: func(cmd *cobra.Command, args []string) { }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + cobra.CheckErr(rootCmd.Execute()) +} + +func init() { + cobra.OnInitialize(initConfig) + + // Here you will define your flags and configuration settings. + // Cobra supports persistent flags, which, if defined here, + // will be global for your application. + + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.fragevents.yaml)") + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } else { + // Find home directory. + home, err := homedir.Dir() + cobra.CheckErr(err) + + // Search config in home directory with name ".fragevents" (without extension). + viper.AddConfigPath(home) + viper.SetConfigName(".fragevents") + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..024346b --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/fragforce/fragevents + +go 1.18 diff --git a/main.go b/main.go new file mode 100644 index 0000000..1d4c29a --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +/* +Copyright © 2022 Paulson McIntyre + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +package main + +import "github.com/fragforce/fragevents/cmd" + +func main() { + cmd.Execute() +}