Skip to content
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

Merged
merged 4 commits into from
Jan 3, 2024

Conversation

tadeohepperle
Copy link
Contributor

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 running parachain-node export-metadata | subxt codegen --file -.

@tadeohepperle tadeohepperle requested a review from a team as a code owner January 3, 2024 12:26
impl FromStr for PathOrStdIn {
type Err = <PathBuf as FromStr>::Err;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Copy link
Member

@niklasad1 niklasad1 Jan 3, 2024

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 -

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

@jsdw jsdw Jan 3, 2024

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!)

Copy link
Member

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 :)

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

LGTM, nice one!

@tadeohepperle tadeohepperle merged commit d15579a into master Jan 3, 2024
11 checks passed
@tadeohepperle tadeohepperle deleted the tadeohepperle/cli-accept-input-via-std-in branch January 3, 2024 22:31
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.

subxt codegen should support the input of metadata through stdin
3 participants