Skip to content

Commit

Permalink
import: allow skipping members (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonehusin authored May 1, 2024
1 parent b159bd3 commit 7ac2838
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ func importTeams(ctx context.Context, provider pager.Pager, fh *firehydrant.Clie
console.Successf("Found %d teams on FireHydrant.\n", len(fhTeams))

if err := provider.LoadTeamMembers(ctx); err != nil {
return fmt.Errorf("unable to populate team members: %w", err)
console.Errorf("unable to load team members: %s", err.Error())
if y, yErr := console.YesNo("Continue without team members?"); yErr != nil || !y {
return fmt.Errorf("unable to populate team members: %w", err)
}
}

// First, we prompt users which teams to import to FireHydrant from the external provider.
Expand Down
8 changes: 8 additions & 0 deletions console/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ func MultiSelectf[T any](options []T, toString func(T) string, title string, arg

return values, selected, nil
}

func YesNo(title string, args ...any) (bool, error) {
response, _, err := Selectf([]string{"Yes", "No"}, func(s string) string { return s }, title, args...)
if err != nil {
return false, fmt.Errorf("selecting yes/no: %w", err)
}
return response == 0, nil
}

0 comments on commit 7ac2838

Please sign in to comment.