Skip to content

feat: collect workflow inputs via command line#597

Draft
morgante wants to merge 3 commits intomainfrom
dynamic-workflow-args
Draft

feat: collect workflow inputs via command line#597
morgante wants to merge 3 commits intomainfrom
dynamic-workflow-args

Conversation

@morgante
Copy link
Collaborator

@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