mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Added cache path flag
This commit is contained in:
parent
92f624239d
commit
f2e5720aaa
1 changed files with 7 additions and 6 deletions
11
cmd/root.go
11
cmd/root.go
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
configPath = ""
|
||||
confPath = ""
|
||||
config opaal.Config
|
||||
)
|
||||
var rootCmd = &cobra.Command{
|
||||
|
|
@ -30,18 +30,19 @@ func Execute() {
|
|||
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
rootCmd.PersistentFlags().StringVar(&configPath, "config", "", "set the config path")
|
||||
rootCmd.PersistentFlags().StringVar(&confPath, "config", "", "set the config path")
|
||||
rootCmd.PersistentFlags().StringVar(&config.Options.CachePath, "cache", "", "set the cache path")
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
// load config if found or create a new one
|
||||
if configPath != "" {
|
||||
exists, err := pathx.PathExists(configPath)
|
||||
if confPath != "" {
|
||||
exists, err := pathx.PathExists(confPath)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to load config")
|
||||
os.Exit(1)
|
||||
} else if exists {
|
||||
config = opaal.LoadConfig(configPath)
|
||||
config = opaal.LoadConfig(confPath)
|
||||
} else {
|
||||
config = opaal.NewConfig()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue