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

Make ockam node delete (no args) interactive by asking the user to choose from a list of nodes to delete (tuify) #6450

Closed
nazmulidris opened this issue Oct 10, 2023 · 5 comments · Fixed by #6480
Assignees
Labels
Component: Command hacktoberfest Apply to issues you want contributors to help with help wanted Type: User Experience

Comments

@nazmulidris
Copy link
Contributor

nazmulidris commented Oct 10, 2023

Current behavior

When a user runs ockam node delete without any arguments, currently they are prompted to delete the default node. Here's a screenshot of this.

Image

Desired behavior

Instead of deleting the default node, change the behavior of this command so that it becomes interactive with the user. Note that this can only be allowed to happen if:

  • the terminal is interactive, and,
  • the --no-input or --quiet flags have not been passed, and,
  • no arguments have been passed in to the command.

This what the user flow should look like in interactive mode.

  1. Use the tuify crate's select_from_list() function to ask the user to select from a list of node names. They should be able to make multiple selections. If there are none, then simply display a message saying that none exist (not an error) and exit.

  2. Once the user has made their selection(s), display a confirmation prompt letting the user know that that a destructive operation is about to take place with the node names they have selected. Use select_from_list() to display this prompt. They should be able to make a single selection.

    • If they have made no selections then exit by displaying a message to the user letting them know they did not make any selection.
  3. If they choose "YES", then delete each selected node, and display a success / failure message for each node that got deleted.

    • If an operation succeeds then use the ✅ emoji as a prefix for the message.
    • And if it fails, then use the ⚠️ emoji as a prefix for the message.

The following is a video showing a generic user flow that shows the user experience when a user is asked to choose a from a list of "things". Then an action is performed on each "thing". Finally status information is reported for each action that is performed on each "thing". Please note that this flow is not specific to this issue.
Image
https://asciinema.org/a/612547

Implementation details

  • If it hasn't been added already, please add the tuify crate the Cargo.toml file here by adding this line r3bl_tuify = "0.1.16" to the [dependencies] section.
  • You can learn more about how to use the select_from_list() in the tuify crate here. Here is an example that is very similar to the steps you might have to take for this issue.
  • Here's a file you can look at to detect when a terminal is interactive or not.
  • Here's a file you can look at to see where the ockam node delete command is implemented.

We love helping new contributors! ❤️
If you have questions or need help as you explore, please join us on Discord. If you're looking for other issues to contribute to, please checkout our good first issues.

@mickm3n
Copy link
Contributor

mickm3n commented Oct 11, 2023

I'd like to work on this. Please assign this issue to me.

@mrinalwadhwa
Copy link
Member

@mickm3n That's awesome, all yours.
Please let us know if your have any questions as you explore. You can also ask questions on the contributors discord https://discord.gg/RAbjRr3kds

@mickm3n
Copy link
Contributor

mickm3n commented Oct 12, 2023

@mrinalwadhwa
I have a question about the desired behavior. In delete all nodes, it would also delete multiple nodes. Should we align the output of delete all nodes and delete selected nodes? With the same rule:

If an operation succeeds then use the ✅ emoji as a prefix for the message.
And if it fails, then use the ⚠️ emoji as a prefix for the message.

@mickm3n
Copy link
Contributor

mickm3n commented Oct 12, 2023

@mrinalwadhwa
Another question: what's the desired behavior when the terminal is not interactive? Deleting the default node or displaying an error message to the user?

@nazmulidris
Copy link
Contributor Author

I have a question about the desired behavior. In delete all nodes, it would also delete multiple nodes. Should we align the output of delete all nodes and delete selected nodes? With the same rule:

If an operation succeeds then use the ✅ emoji as a prefix for the message.
And if it fails, then use the ⚠️ emoji as a prefix for the message.

@mickm3n The scope of ockam node delete --all is not part of this issue, so it is best not to change that in this PR. We can create a new issue for that after this PR is landed.

Another question: what's the desired behavior when the terminal is not interactive? Deleting the default node or displaying an error message to the user?

Retain the current behavior when the terminal is not interactive.

@mickm3n mickm3n mentioned this issue Oct 13, 2023
5 tasks
@nazmulidris nazmulidris linked a pull request Oct 16, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Command hacktoberfest Apply to issues you want contributors to help with help wanted Type: User Experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants