Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import: allow skipping members #28

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol the function name is perfect

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could have been yes_no? if ruby

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
}