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

Do not show usage error for --all flag #960

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions src/app/cli/src/commands/repository_delete_command.rs
Copy link
Member

Choose a reason for hiding this comment

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

Optional: add E2E tests -- Here it would be great to check our errors (output messages)

PS. I'd like to help make these, if you decide to make them, let me know and I'll advise on the best way to approach it

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl RepositoryDeleteCommand {
#[async_trait::async_trait(?Send)]
impl Command for RepositoryDeleteCommand {
async fn run(&mut self) -> Result<(), CLIError> {
if self.names.is_empty() && !self.all {
return Err(CLIError::usage_error(
"Specify a repository or use --all flag",
));
}

Comment on lines +49 to +54
Copy link
Member

Choose a reason for hiding this comment

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

Please use (override) Command::validate_args() for this check

Copy link
Member

Choose a reason for hiding this comment

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

Also, I think we should work through all the variations

  1. no names & no --all
  2. no names & --all
  3. some names & no --all
  4. some names & --all

I think some of these options are redundant and an error message should be provided for them

let repo_names: Vec<_> = if self.all {
self.remote_repo_reg.get_all_repositories().collect()
} else {
Expand All @@ -58,9 +64,11 @@ impl Command for RepositoryDeleteCommand {
};

if repo_names.is_empty() {
return Err(CLIError::usage_error(
"Specify a repository or use --all flag",
));
eprintln!(
"{}",
console::style("There are no repositories to delete").yellow()
);
return Ok(());
}

self.interact.require_confirmation(format!(
Expand Down
Loading