Skip to content

Conversation

@sophacles
Copy link

Took on a first pass at the refactoring I suggested in #276 to see how
much work it was. This commit does it. The major things:

  • Create an InvokeProgram subclass of Program, for the invoke command.
  • Rearrange how the arguments are handled a bit:
    • Move task related arguments to core_args in InvokeProgram
    • split argument handling out of _parse
    • Add a few functions for stages of argument handling
  • remove references to argument values from Program for all arguments
    that are not in core_args
  • fix up tests to run
  • rearrange tests to differentiate between Program tests and
    InvokeProgram tests
    • new test file invoke_program.py
    • new _utils function expect_inv to run integration tests with the
      InvokeProgram subclass rather than the Program class

An important note here, even if this work is not the best direction to
take invoke is that there are a few places in program where core args
and task args are mixed together and expected. These cause problems for
developers creating their own "binaries" from Program:

  • In Program the method load_collection expects args to have
    args.root and args.collection defined (whether or not they have a
    value)
  • In Program the config property expects args['no-dedupe'] to be
    defined

Took on a first pass at the refactoring I suggested in pyinvoke#276 to see how
much work it was. This commit does it. The major things:

* Create an InvokeProgram subclass of Program, for the `invoke` command.
* Rearrange how the arguments are handled a bit:
  + Move task related arguments to `core_args` in `InvokeProgram`
  + split argument handling out of `_parse`
  + Add a few functions for stages of argument handling
* remove references to argument values from `Program` for all arguments
  that are not in `core_args`
* fix up tests to run
* rearrange tests to differentiate between `Program` tests and
  `InvokeProgram` tests
  + new test file `invoke_program.py`
  + new `_utils` function expect_inv to run integration tests with the
  `InvokeProgram` subclass rather than the `Program` class

An important note here, even if this work is not the best direction to
take invoke is that there are a few places in program where core args
and task args are mixed together and expected. These cause problems for
developers creating their own "binaries" from `Program`:

* In `Program` the method `load_collection` expects args to have
  `args.root` and `args.collection` defined (whether or not they have a
  value)
* In `Program` the `config` property expects `args['no-dedupe']` to be
  defined
invoke/main.py Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • F401 'enable_logging' imported but unused

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.

2 participants