Closed shimpeko closed 1 year ago
Base: 47.86% // Head: 48.15% // Increases project coverage by +0.28%
:tada:
Coverage data is based on head (
cfca4da
) compared to base (e34c621
). Patch coverage: 59.61% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I have a few questions about the implementation but I think the root cause of why I have them is that there is not documentation on how to use the patterns you are introducing in this code. If I wanted to add pass through functionality to a different command, I wouldn't know how.
Can you please write a documentation into the README on how to make commands pass through? Trying to explain it might result in changes of the implementation as well.
I've explained it on a docstring hope it explains how to use it. I've avoided README as is more about how we design commands rather than Delfino's functionality.
Discussed offline as https://github.com/radeklat/delfino/issues/34#issuecomment-1256142952
@radeklat I have three options for implementation and I think Option 1 is the best because of the following reason. Can I have your thought?
delfino lint --pylint-option xxx --pydocstyle-option yyy
allow_unknow_options
in the way of Option3 is discouraged.The downside of option 1 is a complex UI.
--CMD-option
@click.command()
@click.option("--mypy-option", type=str, callback=shlex.split) # callback is to split option value and make it list of str
def typecheck(mypy_option: List[str]):
run(["mypy", *mypy_option])
$ delfino typecheck --mypy-option '--huga path_to_file'
-> run `mypy --huga path_to_file`
The implementation of a helper decorator for this option can be found here.
@click.command()
@click.argument("mypy_option", type=str, nargs=-1) # nargs=-1 will accept unlimited number of args
def typecheck(mypy_option: List[str], mypy_option: List[str]):
run(["mypy", *mypy_option])
$ delfino typecheck path_to_file
-> run `mypy path_to_file`
$ delfino typecheck --huga path_to_file
-> raise error as `--huga` option is not defined
$ delfino typecheck -- --huga path_to_file' # All values after `--` will be considered as arg
-> run `mypy --huga path_to_file`
@click.command(allow_unknow_options=True, allow_extra_args=True) # will pass all undefined options + argument in to click_context.args
@click.pass_context
def typecheck(mypy_option: List[str], click_context: click.Context):
run(["mypy", *click_context.args])
$ delfino typecheck --huga path_to_file
-> run `mypy --huga path_to_file`
The implementation of helper decorator for this option can be found here.
Finished as part of #49. Thank you for the research of the options and base functionality.
closes https://github.com/radeklat/delfino/issues/34
Implement https://github.com/radeklat/delfino/issues/34 for test-related commands,
test-unit
andtest-integration
.These command now can pass options/arguments to its underlying command,
pytest
. Options/arguments to be passed, pass-through options/arguments, can be configured in two ways; config file and command line argument.Please see this docstring for detail usage.