-
Notifications
You must be signed in to change notification settings - Fork 251
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
Error if user follows a non-existent component #951
Conversation
crates/trigger/src/stdio.rs
Outdated
let unknown_names: Vec<_> = names | ||
.iter() | ||
.filter(|name| !component_ids.contains(name.as_str())) | ||
.collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let unknown_names: Vec<_> = names | |
.iter() | |
.filter(|name| !component_ids.contains(name.as_str())) | |
.collect(); | |
let unknown_names: Vec<_> = names.difference(&component_ids).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bah, I knew that had to exist somewhere. Thank you!
I've checked it locally, and it works great! |
.map(|item| format!(" - {item}")) | ||
.collect::<Vec<_>>() | ||
.join("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost equivalent (but with extra trailing \n):
.map(|item| format!(" - {item}")) | |
.collect::<Vec<_>>() | |
.join("\n") | |
.map(|item| format!(" - {item}\n")) | |
.collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's nice, but because I return the error message rather than fully controlling the printing it means, I end up with a blank line between the error and the exit code message:
$ spin up --follow godby --follow helo
Error: The following component(s) specified in --follow do not exist in the application:
- helo
- godby
The following components exist:
- gogogo
- hello
- goodbyte
Error: exit status: 1
...which is neither here nor there, I'm sure, but I slightly prefer the more compact form. If we can get rid of the exit status message then this would be a good change. (And thanks for mentioning it, I didn't know collecting to String did this. Though now I do I'm not sure how I feel about it!)
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
b130e1d
to
663a63f
Compare
Fixes #944.
If a non-existent component is specified in
--follow
, Spin now exits with this message:(I don't know where the "exit status 1" comes from - is that an artefact of the
spin trigger
command failing and that output being reported byspin up
@lann?)(cc @etehtsea - it won't let me add you as a reviewer)
Signed-off-by: itowlson ivan.towlson@fermyon.com