diff --git a/cmd/obp/cmd/hugo.go b/cmd/obp/cmd/hugo.go index 2197c26..b380143 100644 --- a/cmd/obp/cmd/hugo.go +++ b/cmd/obp/cmd/hugo.go @@ -4,11 +4,15 @@ Copyright © 2023 NAME HERE package cmd import ( + "log" // "fmt" "github.com/spf13/cobra" + "github.com/spf13/viper" ) +var source, target string + var hugoCmd = &cobra.Command{ Use: "hugo", Short: "convert a set of Obsidian notes into a Hugo compatible directory structure", @@ -23,8 +27,19 @@ var hugoCmd = &cobra.Command{ } func init() { - // hugoCmd.Flags().StringVar(&source, "source", "", "directory containing ready-to-publish posts") - // hugoCmd.Flags().StringVar(&target, "target", "", "target Hugo directory (typically content/posts)") + hugoCmd.Flags().StringP("source", "s", "", "path to vault directory containing hugo posts") + hugoCmd.Flags().StringP("target", "t", "", "hugo content/ directory") + hugoCmd.MarkFlagsRequiredTogether("source", "target") + + err := viper.BindPFlag("source", hugoCmd.Flags().Lookup("schema")) + if err != nil { + log.Panicln("error binding viper to source flag:", err) + } + + err = viper.BindPFlag("target", hugoCmd.Flags().Lookup("target")) + if err != nil { + log.Panicln("error binding viper to target flag:", err) + } rootCmd.AddCommand(hugoCmd) } diff --git a/cmd/obp/cmd/validate.go b/cmd/obp/cmd/validate.go index e4a8162..8ae2617 100644 --- a/cmd/obp/cmd/validate.go +++ b/cmd/obp/cmd/validate.go @@ -75,7 +75,6 @@ func init() { validateCmd.Flags().StringP("target", "t", "", "directory containing validation targets") validateCmd.MarkFlagsRequiredTogether("schema", "target") validateCmd.PersistentFlags().StringVar(&format, "format", "markdown", "output format [markdown, json, csv]") - rootCmd.AddCommand(validateCmd) err := viper.BindPFlag("schema", validateCmd.Flags().Lookup("schema")) if err != nil { @@ -91,4 +90,6 @@ func init() { if err != nil { log.Panicln("error binding viper to format flag:", err) } + + rootCmd.AddCommand(validateCmd) } diff --git a/hugo.go b/hugo.go new file mode 100644 index 0000000..6df7de1 --- /dev/null +++ b/hugo.go @@ -0,0 +1,13 @@ +package obp + +func Copy(src, dst string) error { + return nil +} + +func Sanitize(src string) error { + return nil +} + +func GatherMedia(src string) error { + return nil +}