Default config dir.
This commit is contained in:
parent
4bfaf12de7
commit
f1d4e0a8d5
1 changed files with 9 additions and 2 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/AYM1607/ccclip/internal/configfile"
|
"github.com/AYM1607/ccclip/internal/configfile"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -18,9 +21,13 @@ var rootCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringVarP(&configfile.Path, "config-path", "c", "", "directory where to store the config file")
|
homeDir, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("could not locate home directory: %s", err.Error()))
|
||||||
|
}
|
||||||
|
defualtConfigPath := path.Join(homeDir, ".config", "ccclip")
|
||||||
|
|
||||||
rootCmd.MarkPersistentFlagRequired("config-path")
|
rootCmd.PersistentFlags().StringVar(&configfile.Path, "config-dir", defualtConfigPath, "location of the ccclip.yaml configuration file")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue