Skip to content

Commit

Permalink
Add option to cancel package editing
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Mar 27, 2021
1 parent 8a54996 commit fd17852
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bin/commands/manage_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ class ManageCommand extends Command {
/// Allow the user to change any values of the [package] object.
var exit = false;
while(!exit) {
const fields = ['name', 'description', 'url', 'tags', 'Done, save'];
const fields = ['name', 'description', 'url', 'tags', 'Done, save', 'Cancel'];
final chosenFieldToEdit = Select(
prompt: 'Which value do you want to edit?',
options: fields,
).interact();

/// If they selected 'Done, save', we'll exit this loop and send the new data to the API.
if (chosenFieldToEdit == fields.length - 1) {
if (chosenFieldToEdit == fields.indexOf('Done, save')) {
/// If they selected 'Done, save', we'll exit this loop and send the new data to the API.
exit = true;
break;
} else if (chosenFieldToEdit == fields.indexOf('Cancel')) {
/// If they selected 'Cancel', we'll simply return this function and discard any data.
return;
}

switch (fields[chosenFieldToEdit]) {
Expand Down

0 comments on commit fd17852

Please sign in to comment.