mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 11:37:01 -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 (
|
var (
|
||||||
configPath = ""
|
confPath = ""
|
||||||
config opaal.Config
|
config opaal.Config
|
||||||
)
|
)
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
|
|
@ -30,18 +30,19 @@ func Execute() {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cobra.OnInitialize(initConfig)
|
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() {
|
func initConfig() {
|
||||||
// load config if found or create a new one
|
// load config if found or create a new one
|
||||||
if configPath != "" {
|
if confPath != "" {
|
||||||
exists, err := pathx.PathExists(configPath)
|
exists, err := pathx.PathExists(confPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to load config")
|
fmt.Printf("failed to load config")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
} else if exists {
|
} else if exists {
|
||||||
config = opaal.LoadConfig(configPath)
|
config = opaal.LoadConfig(confPath)
|
||||||
} else {
|
} else {
|
||||||
config = opaal.NewConfig()
|
config = opaal.NewConfig()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue