← Back to issue list

Simplify the Dispatcher usage

View original Github issue

Metadata

Project
craft-cli
Number
#56
Type
issue
State
open
Author
facundobatista
Labels
Status: Triaged Type: Refactor
Created
2022-01-25 18:52:27+00:00
Updated
2025-09-17 21:06:52+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

Currently, before instantiaton, the following steps are needed: - `pre_parse_args`: will parse all arguments and return all global args, *very* useful for the app to react on custom global arguments - `load_command`: useful to pass the loaded app config - `run`: finally run the command We could have a more simple usage. Two models are described below: **The explicit one:** Let's provide a `simple_run` method (name to be determined) that will be the equivalent to: ``` dispatcher.pre_parse_args(sys.argv[1:]) # sys.argv usage by default, and no use of returned global args dispatcher.load_command(None) # no app config passed dispatcher.run() ``` **The implicit one:** We can assume no special needs in the previous step, and run it implicitly in case it was not run explicitly before: - if the developer called `load_command` without calling `pre_parse_args` before, just call `pre_parse_args(sys.argv[1:])`. - if the developer called `run` without calling `load_command`, just call `load_command(None)` (which may trigger previous item too)

Evaluation history

No evaluation history available.