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 project delete (no args) interactive by asking the user to choose from a list of space and project names to delete (tuify) #6461

Open
nazmulidris opened this issue Oct 12, 2023 · 5 comments
Assignees

Comments

@nazmulidris
Copy link
Contributor

nazmulidris commented Oct 12, 2023

Current behavior

When a user runs ockam project delete without any arguments, currently they are shown an error & some help text is displayed asking them to provide the <SPACE_NAME> and <PROJECT_NAME>. Here's a screenshot of this.

Image

Desired behavior

Instead of displaying this help text, 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.

The user needs to be asked for 2 things:

  1. one <SPACE_NAME>
  2. one or more <PROJECT_NAME>

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 space names. They should be able to make a single selection. If there are none, then simply display a message saying that none exist (not an error) and exit.

  2. Use the tuify crate's select_from_list() function to ask the user to select from a list of project names (for their given space name). They should be able to make a multiple selections.

  3. 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 space name and project name(s) (belonging to that space) 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.
  4. If they choose "YES", then delete each selected project from the space, and display a success / failure message for each project that got deleted from the space.

    • 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

  • Please use the functions select_multiple, and confirm_interactively in this file.

  • Here's a similar PR to get some ideas from: delete node interactively #6480

  • 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 project 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.

@biesnecker
Copy link

Hi, I would be interested in taking this on. I'll start to poke at the code and see if I have any questions.

@nazmulidris
Copy link
Contributor Author

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

@biesnecker
Copy link

I asked on Discord but will record here too:

Hi, I'm looking at #6461, and running into an error when I try to make the space_name and project_name options optional in the delete command. The actual error I get is:

future cannot be sent between threads safely
future returned by `rpc` is not `Send`rustcClick for full compiler diagnostic
delete.rs(56, 6): opaque type is declared here
delete.rs(43, 12): this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
delete.rs(49, 5): future is not `Send` as it awaits another future which is not `Send`
mod.rs(51, 62): required by a bound in `node_rpc`

I more or less understand what it's saying, but I don't understand how switching from String to Option<String> would cause it. miette::Result doesn't change. The example PR given (#6480) uses local_cmd rather than node_rpc, which might be why it wasn't an issue in that one?

@Lumexralph
Copy link
Contributor

If this issue is not yet done, please, can you assign it to me?

@nazmulidris
Copy link
Contributor Author

@Lumexralph It is all yours! 👍🏽

@nazmulidris nazmulidris assigned Lumexralph and unassigned biesnecker Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants