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

Implement parse and dispatch strategy for executing subcommands #196

Closed
SeanBryan51 opened this issue Nov 1, 2023 · 0 comments · Fixed by #198
Closed

Implement parse and dispatch strategy for executing subcommands #196

SeanBryan51 opened this issue Nov 1, 2023 · 0 comments · Fixed by #198
Assignees

Comments

@SeanBryan51
Copy link
Collaborator

SeanBryan51 commented Nov 1, 2023

The current method of executing subcommands can be improved using a "parse and dispatch" strategy. Whereby you don't need to run a conditional to work out which subcommand to use.

See: https://github.com/AusClimateService/axiom/blob/54de78d3c490800bdf6806e15a1e8d23f2e82430/bin/axiom#L207

I basically set the desired command as a default on the sub parser and then pop it to call when dispatching.

https://github.com/AusClimateService/axiom/blob/54de78d3c490800bdf6806e15a1e8d23f2e82430/bin/axiom#L15

Originally posted by @bschroeter in #191 (review)

@SeanBryan51 SeanBryan51 self-assigned this Nov 1, 2023
SeanBryan51 added a commit that referenced this issue Nov 2, 2023
The current method of executing subcommands can be improved using a
"parse and dispatch" strategy. Whereby you don't need to run a
conditional to work out which subcommand to use.

This change refactors the Benchcab class so that its "public" methods
can be dispatched easily when inspecting the argparse.Namespace object
returned by the command line parser.

Fixes #196
@SeanBryan51 SeanBryan51 linked a pull request Nov 2, 2023 that will close this issue
SeanBryan51 added a commit that referenced this issue Nov 2, 2023
The current method of executing subcommands can be improved using a
"parse and dispatch" strategy. Whereby you don't need to run a
conditional to work out which subcommand to use.

This change refactors the Benchcab class so that its "public" methods
can be dispatched easily when inspecting the argparse.Namespace object
returned by the command line parser.

Fixes #196
SeanBryan51 added a commit that referenced this issue Nov 2, 2023
The current method of executing subcommands can be improved using a
"parse and dispatch" strategy. Whereby you don't need to run a
conditional to work out which subcommand to use.

This change refactors the Benchcab class so that its "public" methods
can be dispatched easily when inspecting the argparse.Namespace object
returned by the command line parser.

Fixes #196
SeanBryan51 added a commit that referenced this issue Nov 2, 2023
The current method of executing subcommands can be improved using a
"parse and dispatch" strategy. Whereby you don't need to run a
conditional to work out which subcommand to use.

This change refactors the Benchcab class so that its "public" methods
can be dispatched easily when inspecting the argparse.Namespace object
returned by the command line parser.

Fixes #196
SeanBryan51 added a commit that referenced this issue Nov 6, 2023
The current method of executing subcommands can be improved using a
"parse and dispatch" strategy. Whereby you don't need to run a
conditional to work out which subcommand to use.

This change refactors the Benchcab class so that its "public" methods
can be dispatched easily when inspecting the argparse.Namespace object
returned by the command line parser.

Fixes #196
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 a pull request may close this issue.

1 participant