Skip to content

Commit

Permalink
handle persistent flag error, gci
Browse files Browse the repository at this point in the history
  • Loading branch information
zeucapua committed Oct 3, 2024
1 parent d19e8d1 commit c18ca72
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions cmd/offboard/offboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,28 @@ 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
}

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)
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/posthog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}

Expand All @@ -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",
})
}

Expand Down

0 comments on commit c18ca72

Please sign in to comment.