frostyx / copr / copr

Forked from copr/copr 7 years ago
Clone

31ef90d [cli] do not require to set PyPI packagename when it is already set

1 file Authored by frostyx 5 years ago, Committed by frostyx 5 years ago,
    [cli] do not require to set PyPI packagename when it is already set
    
    Basically, we use the same function (`action_add_or_edit_package_pypi`)
    and parser (`parser_pypi_args_parent`) for both adding and editing PyPI packages.
    Now, having the same parser means, that when editing, it requires
    the same parameters as adding (currently we are talking only about `--packagename`).
    
    Of course, it is necessary to specify `packagename` when adding new PyPI package.
    It is also necessary to specify `packagename` when editing the package from
    e.g. SCM method, to the PyPI method (because don't forget, `packagename`
    is not the name of the package in the Copr, but rather the name of
    the package in PyPI). However, when just editing a PyPI package
    (not changing to it from some other method), user should not be required
    to specify `--packagename` because it is already set in Copr.
    User may want to change it, but shouldn't be required to.
    
    This commit changes the parsers in order to not explicitly require
    `--packagename` when editing a package. There is a validator on the frontend,
    so it shouldn't be possible to create a package without it anyway.
    
    There is an attribute `conflict_handler="resolve"` for the parser,
    which should allow overriding a parameter of parent parser (so we could just set
    `required=False` for `--packagename` in `parser_edit_package_pypi`, but
    there is a bug in this conflict_handler that damages the parent parsers
    (and therefore breaks other commands), so I needed to workaround it by creating
    `parser_pypi_args_optional`.
    
        
file modified
+10 -6