|
|
@ -12,7 +12,10 @@ import (
|
|
|
|
// "code.ndumas.com/ndumas/obsidian-pipeline/gloss"
|
|
|
|
// "code.ndumas.com/ndumas/obsidian-pipeline/gloss"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var cfgFile string
|
|
|
|
var (
|
|
|
|
|
|
|
|
vault string
|
|
|
|
|
|
|
|
cfgFile string
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// rootCmd represents the base command when called without any subcommands
|
|
|
|
// rootCmd represents the base command when called without any subcommands
|
|
|
|
var rootCmd = &cobra.Command{
|
|
|
|
var rootCmd = &cobra.Command{
|
|
|
@ -42,7 +45,9 @@ func init() {
|
|
|
|
// Cobra supports persistent flags, which, if defined here,
|
|
|
|
// Cobra supports persistent flags, which, if defined here,
|
|
|
|
// will be global for your application.
|
|
|
|
// will be global for your application.
|
|
|
|
|
|
|
|
|
|
|
|
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.obp.toml)")
|
|
|
|
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "~/.obp.toml", "config file")
|
|
|
|
|
|
|
|
rootCmd.PersistentFlags().StringVar(&vault, "vault", "", "vault root directory")
|
|
|
|
|
|
|
|
rootCmd.MarkPersistentFlagRequired("vault")
|
|
|
|
|
|
|
|
|
|
|
|
// Cobra also supports local flags, which will only run
|
|
|
|
// Cobra also supports local flags, which will only run
|
|
|
|
// when this action is called directly.
|
|
|
|
// when this action is called directly.
|
|
|
@ -55,7 +60,6 @@ func init() {
|
|
|
|
// initConfig reads in config file and ENV variables if set.
|
|
|
|
// initConfig reads in config file and ENV variables if set.
|
|
|
|
func initConfig() {
|
|
|
|
func initConfig() {
|
|
|
|
if cfgFile != "" {
|
|
|
|
if cfgFile != "" {
|
|
|
|
// Use config file from the flag.
|
|
|
|
|
|
|
|
viper.SetConfigFile(cfgFile)
|
|
|
|
viper.SetConfigFile(cfgFile)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Find home directory.
|
|
|
|
// Find home directory.
|
|
|
|