diff --git a/cmd/offboard/offboard.go b/cmd/offboard/offboard.go index 1b6c410..4e282f9 100644 --- a/cmd/offboard/offboard.go +++ b/cmd/offboard/offboard.go @@ -62,8 +62,10 @@ func NewConfigCommand() *cobra.Command { }, } - cmd.Flags().StringP("path", "p", "", "the path to the repository") - cmd.MarkFlagRequired("path") + cmd.PersistentFlags().StringP("path", "p", "", "the path to the repository (required)") + if err := cmd.MarkPersistentFlagRequired("path"); err != nil { + fmt.Printf("error MarkPersistentFlagRequired: %v", err) + } return cmd } @@ -71,20 +73,17 @@ func run(opts *Options) error { var spec *config.Spec var err error if len(opts.configPath) != 0 { - fmt.Printf("IF != 0 %s", opts.configPath) spec, _, err = config.LoadConfig(opts.configPath) } else { - var dir string - if (strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0) { - dir = fmt.Sprintf("%s.sauced.yaml", opts.path) + var configPath string + if strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0 { + configPath = opts.path + ".sauced.yaml" } else { - dir = fmt.Sprintf("%s/.sauced.yaml", opts.path) + configPath = opts.path + "/.sauced.yaml" } - fmt.Printf("ELSE %s", dir) - spec, _, err = config.LoadConfig(dir) + spec, _, err = config.LoadConfig(configPath) } - if err != nil { _ = opts.telemetry.CaptureFailedOffboard() return fmt.Errorf("error loading config: %v", err) @@ -112,11 +111,16 @@ func run(opts *Options) error { } } - if len(opts.configPath) != 0 { err = generateConfigFile(opts.configPath, attributions) } else { - err = generateConfigFile(fmt.Sprintf("%s/.sauced.yaml", opts.path), attributions) + var configPath string + if strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0 { + configPath = opts.path + ".sauced.yaml" + } else { + configPath = opts.path + "/.sauced.yaml" + } + err = generateConfigFile(configPath, attributions) } if err != nil { diff --git a/pkg/utils/posthog.go b/pkg/utils/posthog.go index 32503d8..10d66d1 100644 --- a/pkg/utils/posthog.go +++ b/pkg/utils/posthog.go @@ -202,7 +202,7 @@ func (p *PosthogCliClient) CaptureOffboard() error { if p.activated { return p.client.Enqueue(posthog.Capture{ DistinctId: p.uniqueID, - Event: "pizza_cli_offboard", + Event: "pizza_cli_offboard", }) } @@ -213,7 +213,7 @@ func (p *PosthogCliClient) CaptureFailedOffboard() error { if p.activated { return p.client.Enqueue(posthog.Capture{ DistinctId: p.uniqueID, - Event: "pizza_cli_failed_to_offboard", + Event: "pizza_cli_failed_to_offboard", }) }