@@ -4,27 +4,19 @@ import (
44 "fmt"
55 "os"
66
7- homedir "github.com/mitchellh/go-homedir"
7+ "github.com/mitchellh/go-homedir"
88 "github.com/spf13/cobra"
99 "github.com/spf13/viper"
1010)
1111
12- var cfgFile string
13-
14- // rootCmd represents the base command when called without any subcommands
15- var rootCmd = & cobra.Command {
16- Use : "tunnel" ,
17- Short : "A brief description of your application" ,
18- Long : `A longer description that spans multiple lines and likely contains
19- examples and usage of using your application. For example:
20-
21- Cobra is a CLI library for Go that empowers applications.
22- This application is a tool to generate the needed files
23- to quickly create a Cobra application.` ,
24- // Uncomment the following line if your bare application
25- // has an action associated with it:
26- // Run: func(cmd *cobra.Command, args []string) { },
27- }
12+ var (
13+ confFile string
14+ rootCmd = & cobra.Command {
15+ Use : "tunnel" ,
16+ Short : "Tunnel lets you expose local servers to the internet securely" ,
17+ Long : `` ,
18+ }
19+ )
2820
2921// Execute adds all child commands to the root command and sets flags appropriately.
3022// This is called by main.main(). It only needs to happen once to the rootCmd.
@@ -37,22 +29,14 @@ func Execute() {
3729
3830func init () {
3931 cobra .OnInitialize (initConfig )
40-
41- // Here you will define your flags and configuration settings.
42- // Cobra supports persistent flags, which, if defined here,
43- // will be global for your application.
44- rootCmd .PersistentFlags ().StringVar (& cfgFile , "config" , "" , "config file (default is $HOME/.tunnel.yaml)" )
45-
46- // Cobra also supports local flags, which will only run
47- // when this action is called directly.
48- rootCmd .Flags ().BoolP ("toggle" , "t" , false , "Help message for toggle" )
32+ rootCmd .PersistentFlags ().StringVarP (& confFile , "config" , "c" , "" , "config file (default is $HOME/.tunnel.yaml)" )
4933}
5034
5135// initConfig reads in config file and ENV variables if set.
5236func initConfig () {
53- if cfgFile != "" {
37+ if confFile != "" {
5438 // Use config file from the flag.
55- viper .SetConfigFile (cfgFile )
39+ viper .SetConfigFile (confFile )
5640 } else {
5741 // Find home directory.
5842 home , err := homedir .Dir ()
@@ -70,6 +54,6 @@ func initConfig() {
7054
7155 // If a config file is found, read it in.
7256 if err := viper .ReadInConfig (); err == nil {
73- fmt .Println ("Using config file:" , viper .ConfigFileUsed ())
57+ // fmt.Println("Using config file:", viper.ConfigFileUsed())
7458 }
7559}
0 commit comments