未验证 提交 02798cdb 编写于 作者: P Phodal HUANG

refactor: rename unused package

上级 26b83b3b
......@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
. "../adapter/call"
. "../adapter/identifier"
......@@ -34,7 +33,5 @@ var collCmd *cobra.Command = &cobra.Command{
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringP("path", "p", "Code Path", "example -p src/main")
viper.BindPFlag("path", rootCmd.PersistentFlags().Lookup("path"))
}
package cmd
import (
//. "../refactor"
. "../refactor/unused"
. "../refactor/rename"
. "../refactor/unused"
"github.com/spf13/cobra"
)
......
......@@ -2,16 +2,12 @@ package cmd
import (
"fmt"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
// Used for flags.
cfgFile string
userLicense string
cfgFile string
rootCmd = &cobra.Command{
Use: "coca",
......@@ -29,30 +25,6 @@ func Execute() error {
func init() {
rootCmd.AddCommand(collCmd)
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
}
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
//er(err)
}
// Search config in home directory with name ".cobra" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".cobra")
}
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err == nil {
fmt.Println("Using config file:", viper.ConfigFileUsed())
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册