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

feat: collect workflow inputs via command line #597

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

morgante
Copy link
Contributor

@morgante morgante commented Jan 3, 2025

Goal

Workflows should allow inputs to be passed via flags and not just JSON. Ex.

grit apply hello --query=foo
# old: grit apply hello --input='{"query":"foo"}'

Challenges

Clap doesn't really like this, since it mostly expects flags to be defined before parsing.

There are some workarounds in clap-rs/clap#1404, but two notable problems:

  • Collecting positional args at the end conflicts with the positional args for folders on apply (Command apply: Argument 'paths' has the same index as 'inputs' and they are both positional arguments\n\n\t Use Arg::num_args(1..) to allow one positional argument to take multiple values)
  • Values are treated as args, not flags, so we still need to re-parse ourselves

Alternative

  1. Ignore errors and strip out whatever args clap does parse, then send the remaining code to TypeScript for final parsing.
  2. Request the schema from the workflow once it's found, then dynamically parse flags based on the schema. Potentially bad for perf, but probably the best devex since we can still support completions.

@morgante morgante changed the title chore: allow unauthenticated workflow exection feat: collect workflow inputs via command line Jan 3, 2025
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.

1 participant