Comments (22)
I'd enjoy spin new [app_name] -t <template>
.
spin new [app_name] -t
where <template>
is omitted gives you all the templates available to choose from.
spin new [app_name]
with no flags gives you just a spin.toml file in a directory called [app_name]
wdyt?
from spin.
+1 to what Michelle said. The only other request I would like to see is a --init
that initializes the current directory rather than creating a new directory.
from spin.
I guess that would address this as well #1075 - which might be a dup of #16
from spin.
@fibonacci1729 In that case, could/should the template name be positional, or is it better to put it behind the -t
flag? (I'm not trying to argue for a specific outcome here, just figuring out the design space.)
Also I know @michelleN has been arguing for the "just create a spin.toml file" for a looong time and I do want to understand the intended experience because I am sure I am missing something.
from spin.
@fibonacci1729 Interesting! I wonder if we should use the --from
trick we do on spin up
so the user could write spin new myapp -f http-go
or spin new myapp -f component.wasm
or spin new myapp -f path/to/spec
interchangeably, and we figure out which case it is. (With --from-template/--from-component/--from-openapi
longopts if disambiguation is needed.)
from spin.
@itowlson I think you are right but i'd still prefer the --init
because my expectation for -o
all this time had been that a directory named appname
would be created at the value of -o
. TIL
EDIT: confirmed that -o .
<==> --init
from spin.
Yeah we should maybe have done this the other way round...
The only things I can think of are:
- Allow the name as a named parameter as well as a positional one (clap permitting). So your command would become
spin new --name myapp
. - Have a magic syntax for "prompt me for the template ID" e.g.
spin new * myapp
. - Not quite what you asked for, but allow partial/tag matches in the template ID, so you could write
spin new rust myapp
and it would go "here are all your Rust templates."
Of these, the last feels most comfortable but I don't know if would meet what you want to write.
from spin.
The PR you opened seems reasonable. I current ordering is a bit unfortunate, but alas, perhaps this is the best we can do.
from spin.
We could have a rule that if there is one positional arg and it doesn't match a template (possibly within some fancy distance metric), we prompt for the template, and prompt for the name but default it to the positional arg. It feels a bit hairy but would probably work in the 90% case.
More generally we could try harder to make sense of "incorrect" user input e.g. if first arg does not match a template but second one does then quietly swap them. I am slightly wary of teaching people the "wrong" thing, though, because things where we can resolve the ambiguities in interactive mode today may not be resolvable in CI environments tomorrow.
from spin.
This has been marked as a "must have" (release blocker) for Spin 2. I believe the only proposal for implementing it is to reorder the arguments from spin new [<template>] [<name>]
to spin new [<name>] [<template>]
? This would allow users to omit the template. Is that correct?
If this is the proposal, it's an easy change in the code! However, anyone with muscle memory of the existing order would experience a jarring transition (and any scripts that use the existing order will break in non-obvious ways). Are we agreed that the joy it will bring over time is worth the short-term pain? (I'm guessing I'm one of the only people on the planet to actually have that muscle memory, so if it brings two people joy then that's probably a net win!) If so, are there ways we can cushion the change?
Or are there other proposals? We also have #16 in the frame which asks for a specific "empty application" experience., so it would be good to get a comprehensive sense of what we want the app scaffolding experience to look like across the various asks.
from spin.
(For example someone made mention of wanting to be able to create an application in the current directory. This can be done without a breaking change, but if it's a requirement/want then it would be good to have it in mind during any rethink.)
from spin.
Can we get a decision on required behaviour please. It's marked as a release blocker for 2.0 but without some agreement on the desired outcome there's no point starting to code. cc @melissaklein24
from spin.
spin new [app_name] with no flags gives you just a spin.toml file in a directory called [app_name]
This seems to also solve #16
from spin.
Thanks all, appreciate getting some definition on this.
I don't quite get the "a spin.toml file in a directory." What is the spin.toml file? Is it the same as the current http-empty template? Is that the experience people want as the default, rather than the current "prompt for a template"? So if someone did a spin new myapp
it would succeed but the created app would not yet be runnable?
from spin.
Ah right, good catch. Personally, I don't see much value in spin new <appname>
just generating a component/trigger-less spin.toml
. I would think in this situation the user would be prompted for the template to select. In other words, in Michelle's above the -t
flag requires an argument.
from spin.
IIRC the rationale for the -t
flag was because we may want to allow application scaffolding from artefacts other than a template in the near future. E.g. spin new myapp -w component.wasm
or spin new myapp --openapi path/to/my/spec
.
from spin.
I guess some flags might need extra args like an OpenAPI spec in Git might need a branch/rev option.
from spin.
@fibonacci1729 Interesting! I wonder if we should use the
--from
trick we do onspin up
so the user could writespin new myapp -f http-go
orspin new myapp -f component.wasm
orspin new myapp -f path/to/spec
interchangeably, and we figure out which case it is. (With--from-template/--from-component/--from-openapi
longopts if disambiguation is needed.)
That sounds like the best experience!
from spin.
Boo, we already use -f
for the manifest to add to in spin add
.
from spin.
Also I know @michelleN has been arguing for the "just create a spin.toml file" for a looong time and I do want to understand the intended experience because I am sure I am missing something.
I am envisioning a skeleton Spin.toml file for an http Spin app that contains some comments on how to fill in the fields.
spin_manifest_version = "1"
authors = ["Michelle Dhanani <[email protected]>"]
# add a description here
description = ""
name = "some-app"
# the trigger field is used to specify how components are invoked. the http trigger type is the most common # # Spin trigger. This allows components to be invoked via HTTP requests. There are other trigger types.. please see docs.
trigger = { type = "http" }
version = "0.1.0"
# Spin apps can consist of multiple [[component]] sections.
[[component]]
# id is a unique identifier for the component in this spin app, you can specify some alphanumeric string here <add constraints>
id = "component1"
# source is the path to the wasm file that will be executed when this component is invoked
source = ""
# allowed_http_hosts represents what hosts this component can make outbound http requests to
allowed_http_hosts = []
[component.trigger]
# route description here
route = "/..."
[component.build]
# command to build the component, will be used by Spin build
command = ""
from spin.
Thanks for clarifying @michelleN. If we do this I think we're going to need a significant amount of supporting infra to provide:
- Good error messages for when a beginner does
spin build / spin up
on one of these. At the moment I think you'd get some nasty parsing errors, when what it would need to do is recognise the "blank" manifest and say "hey you need to go back and fill out all those fields that spin new created for you." - Improvements to
spin add
so that when a user added a component to one of these, it replaces the "blank" component instead of adding. (Because it's significantly easier tospin add
than to write out all those commands and paths by hand.)
The challenge is that, unlike the empty scaffold, this looks like it has a component, so it requires more smarts to determine that actually there isn't a component, it's still waiting to be filled in. I worry that this leaves new users going "but how do I make it work" rather than having a working "hello world" starting point.
We can of course do this if people want it, but I'm wondering if there are other ways to accomplish the goal that this is aiming at. @michelleN is the motive here the doc comments, the "bring your own language", the not needing to install a template. something else?
from spin.
@fibonacci1729 Is the proposed --init
flag equivalent to the existing -o
flag with the path .
?
from spin.
Related Issues (20)
- Initialization Tasks (e.g. creating database / seeding data) HOT 4
- HTTPS Connection reuse from Spin worker HOT 7
- Support wasi-keyvalue HOT 2
- Support TLS in Redis trigger (`rediss://` scheme) HOT 6
- [governance] Formalizing Spin's status as a multi-stakeholder project HOT 1
- Invalid character `{` in package name HOT 4
- Python smoke test is failing with build errors for unknown reasons.
- Inferencing with `codellama-instruct` fails locally HOT 7
- Docs Question: Making a trigger plugin HOT 9
- Hardcoded default port numbers prevent concurrent execution - consider testing if port is in use HOT 8
- `spin up --listen localhost:0` should log the actual bound port number
- Proposal: "Manifest-less" Single Component Apps HOT 2
- spin watch doesn't rebuild/reconfigure on manifest file changes HOT 6
- Different execution times for python spin app on local machine and Fermyon Cloud HOT 6
- Sleeping in a Spin app breaks traces HOT 1
- Templates: support Cargo workspaces
- Upcoming Security Release of Spin (GHSA-f3h7-gpjj-wcvh) HOT 1
- Support exporting application logs through OTel HOT 3
- spin-v2.4.3-macos-amd64.tar.gz contains the wrong architecture HOT 4
- Template install and upgrade commands use different option for Git/URL.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spin.