Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

itowlson
Copy link
Collaborator

@itowlson itowlson commented Oct 4, 2022

Currently, a developer new to Spin and wanting to create an application needs to manually install templates, and needs to know the ID of the template they want to use.

This PR makes it optional to pass the template ID on the command line. If the template ID is omitted, spin new prompts with a list of installed templates:

image

Additionally, if spin new needs to prompt but no templates are installed, spin new offers to install the "default" set:

image

If the template ID and project name are passed on the command line, spin new continues to behave as it did before.

Note: Because the ID and project name are positional args, this PR necessarily also makes the name optional. It will be prompted for if not provided. This creates an additional experience of spin new <template_id> where you will be prompted for the name but not the template. I don't think this is vastly valuable but it's benign so I haven't worried about it.

Signed-off-by: itowlson [email protected]

let mut input = dialoguer::Input::<String>::new();
input.with_prompt("Enter a name for your new project");
let result = input.interact_text()?;
Ok(result)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this should loop on empty input, printing something like:

Project name is required. (ctrl-c to cancel)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like the dialoguer component already rejects empty input, though it does accept "all spaces." (Which, to my surprise, we actually cope with.) I'll trim and loop for that case just in case (though realistically we're more interested in protecting against Murphy vs. against Machiavelli).

Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

Love this experience, especially the choosing the template scrollbar!

@itowlson itowlson requested a review from lann October 5, 2022 20:57
Copy link
Member

@radu-matei radu-matei left a comment

Choose a reason for hiding this comment

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

The new experience is GREAT!

LGTM

@itowlson itowlson merged commit c86f027 into spinframework:main Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants