-
Notifications
You must be signed in to change notification settings - Fork 825
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
Support multiple input options in cli #600
Conversation
tools/cli/flags.go
Outdated
Name: FlagInputWithAlias, | ||
Usage: "Optional input for the workflow, in JSON format. If there are multiple parameters, concatenate them and separate by space.", | ||
Usage: "Optional input for the workflow, in JSON format. If there are multiple parameters, pass each as a separate input flag.", |
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.
[Nit] do we need to mention anything about the input flag ordering corresponding to the input on the workflow params, or is this implicit enough for a user to get?
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.
It's good point. I would add something like "Order of input flags must be the same as parameters order."
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 they will expect the ordering to matter, i would rather keep the help page relatively simple, focusing on the main information. However we could add this to our docs. I've added an item to Cully regarding the docs
tools/cli/util.go
Outdated
|
||
var jsons []interface{} | ||
for _, jsonRaw := range jsonsRaw { | ||
if len(jsonRaw) == 0 { |
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.
whats the scenario for this? passing an intentionally empty argument? Why would we not just ErrorAndExit in this case? Also, if I have multiple empty arguments and we don't append it to the json array, how do I know which empty argument maps with which order of the parameter?
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.
How do we pass nil
? --input "null"
should work, right? If yes, I would validate this case and ErrorAndExit("Empty input flag. Pass \"null\" for nil parameter value.")
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.
using continue
was indeed not good.
Added support for passing null
inputsRaw = append(inputsRaw, []byte(i)) | ||
} | ||
return inputsRaw | ||
} else if c.IsSet(flagInputFileName) { |
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.
is multiple-file input in the next PR?
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 hope so.
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.
see comments. nothing major though
tools/cli/util.go
Outdated
var inputsRaw [][]byte | ||
for _, i := range *inputs { | ||
if i == "nil" { | ||
ErrorAndExit("Empty input flag. Pass \"null\" for nil parameter value.", nil) |
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.
Can we add this to the help description up above? Folks that don't use GoLang won't even try to use "nil" and so this error message is going to be hard to discover. Then I would just remove this.
tools/cli/util.go
Outdated
for _, i := range *inputs { | ||
if i == "nil" { | ||
ErrorAndExit("Empty input flag. Pass \"null\" for nil parameter value.", nil) | ||
} else if i == "null" { |
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.
[Nit] use string comparison that is case insensitive (https://golang.org/pkg/strings/#example_EqualFold)
What changed?
Fixes #502
Added support for multiple input payloads
tctl workflow start --tq helloWorldGroup --wt main.WorkflowWithInputs --et 60 -i '{"Joker":"Heheheh", "Harley":"Pumpkin!"}' -i '"to infinity and beyond"' -i 'null'
Why?
Before you could specify only one payload as
--input
How did you test it?
Ran the command. Ran tests
Potential risks
Low risk. The code shares some logic with --memo flag