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

fix: mason help make doesn't show command line args in help description #85

Closed
jolexxa opened this issue Jun 18, 2021 · 0 comments · Fixed by #88
Closed

fix: mason help make doesn't show command line args in help description #85

jolexxa opened this issue Jun 18, 2021 · 0 comments · Fixed by #88
Assignees
Labels
bug Something isn't working

Comments

@jolexxa
Copy link

jolexxa commented Jun 18, 2021

Description

Running mason help make doesn't list the args that the make command takes. This is probably a small, unfortunate side effect of the intended behavior with bricks being subcommands. Instead, it outputs the following in a project without any bricks:

Generate code using an existing brick template.

Usage: mason make <subcommand> [arguments]
-h, --help    Print this usage information.

Run "mason help" to see global options.

Steps To Reproduce
mason help make

Expected Behavior
The following:

Generate code using an existing brick template.

Usage: mason make [arguments]
-h, --help           Print this usage information.
-c, --config-path    Path to config json file containing variables.
-o, --output-dir     Directory where to output the generated code.
                     (defaults to ".")

Run "mason help" to see global options.

Additional Context

The problem seems to reside with the structure of the subcommands here:

class _MakeCommand extends MasonCommand {
_MakeCommand(this._brick, {Logger? logger}) : super(logger: logger) {
argParser
..addOption(
'config-path',
abbr: 'c',
help: 'Path to config json file containing variables.',
)
..addOption(
'output-dir',
abbr: 'o',
help: 'Directory where to output the generated code.',
defaultsTo: '.',
);
for (final arg in _brick.vars) {
argParser.addOption(arg);
}
}

Because subcommands are only defined for bricks that have been found earlier, it is omitting the flags from the command altogether which is preventing the args package from generating accurate help:

class MakeCommand extends MasonCommand {
/// {@macro make_command}
MakeCommand({Logger? logger}) : super(logger: logger) {
try {
for (final brick in bricks) {
addSubcommand(_MakeCommand(brick, logger: logger));
}
} catch (e) {
_exception = e;
}
}

I would have submitted a pull request, but I wasn't sure how to do this as this without breaking the flags for each brick subcommand. If you'd like help, feel free to point me in the right direction and I'll see what I can do. 😅

@jolexxa jolexxa added the bug Something isn't working label Jun 18, 2021
@felangel felangel self-assigned this Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants