π§ Dev βΎ Determine why yargs is not returning what's expected #1614
Labels
dev-task
Tasks for the Taqueria Dev Board
needs-verification
Bugs which require reproduction or validation
π Epic|Feature Link
No response
π₯ Definition of Done
π§° Work Description
In the CLI, we parse arguments from the CLI twice.
However, there was a problem found during the internal-tasks-refactor work (#1613 ) in the second run of parsing.
Yargs is used to parse CLI arguments into commands, positional arguments, and option flags.
After yargs parses the CLI arguments, an object representing all options is returned. The command (or in Taqueria terminology, the "task") being invoked is stored in the '_' property. If you were to execute the 'generate types' task, then ')' would be set to
["generate", "types"]
.In the first pass of parsing arguments, the '' property is set to as what we would expect: ["generate", "types"]
In the second pass of parsing, the '' property is truncated for some reason:
["generate"]
Note, this is also present in
main
, and seems to have existed for a while, but only manifested in the internal-tasks-refactor work. The reason being is that the logic of the tasks refactor branch utilizes the '_' property to determine what task is being invoked. In main, we utilize yargs command handlers, which fork execution outside of the main execution pipeline.To get around this at the moment, we just copy the '_' property from the initial pass of parsing arguments to the object resulting from the second pass of parsing. See here: https://github.com/ecadlabs/taqueria/blob/refactor-internal-tasks/cli.ts#L1125
β To Do
βοΈ Acceptance Criteria
We should know why parsing using yargs behaves this way, and remove any hacks that force things to work.
π Scope
Forking yargs.
Code of Conduct
The text was updated successfully, but these errors were encountered: