From 11ebf138fb2ddba44fb9420f2c7ffa149ae1805a Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Sat, 26 Jul 2025 22:15:50 -0500 Subject: [PATCH 1/3] Tell viper that the config is yaml. --- cmd/root.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 9b96a65..83c8f9b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -116,15 +116,16 @@ func initConfig() { os.Exit(1) } - // Search config in home directory with name ".baronial" (without extension). + // Search config in home directory with name ".baronialconf" (without extension). viper.AddConfigPath(home) - viper.SetConfigName(".baronial") + viper.SetConfigName(".baronialconf") + viper.SetConfigType("yaml") } viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { - fmt.Println("Using config file:", viper.ConfigFileUsed()) + logrus.Info("Using config file:", viper.ConfigFileUsed()) } } From 11fe14208d539d4ff4237e3c06428836b8a9d823 Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Sat, 26 Jul 2025 22:41:12 -0500 Subject: [PATCH 2/3] Have commit command enforce set user name and user email --- cmd/commit.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/commit.go b/cmd/commit.go index 55c2de4..b343e19 100644 --- a/cmd/commit.go +++ b/cmd/commit.go @@ -31,6 +31,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cast" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/marstr/baronial/internal/index" ) @@ -141,6 +142,24 @@ var commitCmd = &cobra.Command{ ctx, cancel := RootContext(cmd) defer cancel() + commitTransactionFromFlags.Committer.FullName = viper.GetString("user.name") + commitTransactionFromFlags.Committer.Email = viper.GetString("user.email") + + reqConfigMissing := false + if commitTransactionFromFlags.Committer.FullName == "" { + logrus.Error("config user.name is missing") + reqConfigMissing = true + } + + if commitTransactionFromFlags.Committer.Email == "" { + logrus.Error("config user.email is missing") + reqConfigMissing = true + } + + if reqConfigMissing { + logrus.Fatal(("one or more pieces of required configuration is missing.")) + } + targetDir, err := index.RootDirectory(".") if err != nil { logrus.Fatal(err) From 3eb71424870c0a0df7bce6fdc9459f7326501c97 Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Sat, 26 Jul 2025 22:56:12 -0500 Subject: [PATCH 3/3] Include committer name in pretty print --- internal/format/transaction.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/format/transaction.go b/internal/format/transaction.go index d0f2876..98a08c9 100644 --- a/internal/format/transaction.go +++ b/internal/format/transaction.go @@ -127,6 +127,12 @@ func PrettyPrintTransaction( return err } } + if !subject.Committer.Equal(envelopes.User{}) { + _, err = fmt.Fprintf(output, "Committer: \t%s (%s)\n", subject.Committer.FullName, subject.Committer.Email) + if err != nil { + return err + } + } _, err = fmt.Fprintf(output, "Merchant:\t%s\n", subject.Merchant) if err != nil { return err