spin
spin copied to clipboard
spin new: flag to accept defaults where available
At the moment, spin new prompts for fields like description. If the fields it prompts for are not required by the manifest file, it'd be nice to disable the prompt and leave those optional fields empty. I think this will give us a more streamlined spin new experience.
Hi, can I pick this up? Can you please point me to the files I would need to look at?
new.rs
holds the top level logic for the spin new command. --> https://github.com/fermyon/spin/blob/main/src/commands/new.rs
We'll also need to confirm which fields can be omitted. @fibonacci1729 @itowlson - ya'll have any thoughts on this issue?
Everything in HTTP has sensible defaults. Not sure about Redis. The question is what we want users to think about and what not...
If the request is simply to remove the prompt, you shouldn't need to change new
to make a change like this. Each template defines its own set of questions - you should be able to delete the questions out of the template manifest (and replace the substitutions in the content
directory with the desired fixed values, or remove the entries).
If the request is to allow an empty response to the prompt, that would require changes in the template subsystem, crates/template
, specifically run.rs
(and probably in the template schema, template.rs
). Again, shouldn't need anything in new
itself.
The current experience is
$ spin new http-rust hello-fermyon
Project description:
I'd like to be able to accept defaults and not have to go through the prompt with a flag:
$ spin new http-rust hello-fermyon --accept-defaults
@michelleN Oh! Thanks for clarifying, sorry for being slow.
@deepto98 Okay, I think this will need work in a couple of places:
- If the flag is present, populate the parameter values map from the template defaults. Values passed on the command line or via the values file should still override those defaults (
new
already has amerge_values
function that will help with this).Template
has aparameters()
method which ispub(crate)
but is safe to makepub
. - Set the
description
default to empty string in the four existing templates. - Allow empty strings for string parameters, at least as defaults. (Ideally we should make description optional, but that will need logic that we haven't implemented yet.) This may Just Work - I think the non-empty check is in the UI library not in the constraint validation. If not, you're probably looking at the
TemplateParameter::validate_value
function intemplate.rs
.
Thanks for pitching in here, hope this is enough pointers.
@deepto98 Just wanted to check in with you if you were still working on this issue.
@karthik2804 — I think it would be ok if you wanted to have a look at this issue. Thanks!
@radu-matei I will pick this one up.