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

Allow passing multiple --input-files to workflow commands [#351] #361

Merged
merged 3 commits into from
Oct 16, 2023

Conversation

josh-berry
Copy link
Collaborator

The documentation for how to pass multiple arguments was just wrong--json.Unmarshal() does not support parsing multi-line JSON inputs as separate values.

Fix this by accepting multiple --input-file flags, parsing each one separately, and turning each file into a distinct argument.

Also, check and throw an error if the user tries to use both --input and --input-file, since the old behavior--silently ignoring --input if --input-file is specified--was surprising.

The documentation for how to pass multiple arguments was just
wrong--`json.Unmarshal()` does not support parsing multi-line JSON
inputs as separate values.

Fix this by accepting multiple `--input-file` flags, parsing each one
separately, and turning each file into a distinct argument.

Also, check and throw an error if the user tries to use both `--input`
and `--input-file`, since the old behavior--silently ignoring `--input`
if `--input-file` is specified--was surprising.
@josh-berry josh-berry requested a review from a team October 16, 2023 21:02
Copy link
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

LGTM!


s.Assert().Equal("[1,\"two\",{\"three\":3},[\"a\",\"b\",\"c\"]]", result)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't blocking, but just noting that running a real workflow to completion involves quite a lot of machinery that's not related to argument handling. It might be nice to come up with a more directed way to do this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree; there are a lot of ways to handle this (e.g. checking the workflow arguments server-side without waiting for completion, mocking out parts of the CLI so we don't even need a server, etc.). This was just the most expedient.

@josh-berry josh-berry merged commit 676fd19 into main Oct 16, 2023
16 checks passed
@josh-berry josh-berry deleted the josh/multiple-input-files branch October 16, 2023 23:26
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Added a couple tiny Go tips for future

common/util.go Show resolved Hide resolved
tests/workflow_test.go Show resolved Hide resolved
josh-berry added a commit that referenced this pull request Oct 17, 2023
Chad gave me a few style suggestions after I merged #361--this applies
those style suggestions.
josh-berry added a commit that referenced this pull request Oct 20, 2023
Chad gave me a few style suggestions after I merged #361--this applies
those style suggestions.
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.

3 participants