-
Notifications
You must be signed in to change notification settings - Fork 248
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
CLI Tool: Allow using --file -
to read metadata from stdin
#1336
CLI Tool: Allow using --file -
to read metadata from stdin
#1336
Conversation
impl FromStr for PathOrStdIn { | ||
type Err = <PathBuf as FromStr>::Err; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { |
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.
I wonder whether we should trim the leading and trailing whitespaces before checking that the --file -
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.
and a simple test for the from_str
impl would be nice to have.
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.
I think regarding trimming, clap
already takes care of that before the args are given to us to parse, but I am not entirely sure.
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.
worth a quick check but I'd assume the shell would handle it :)
(and if the user provides something like ' - '
as an argument then I wouldn't expect that to be treated as stdin anyways. Edit: Ah I can see it's trimmed now; that's fine too; either way works!)
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.
Tadeo added trimming and tests for it :)
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.
LGTM, nice one!
fixes #1326
I tested it manually by running
subxt metadata | subxt codegen --file -
(which is not super useful obviously) but shows that it works for the requested usecase of runningparachain-node export-metadata | subxt codegen --file -
.