(option, help="", default=None, )
return decorator
A class decorator that adds a boolean --with(out)-option cmd line switch
    to a distutils.cmd.Command class

    Parameters
    ----------
    option : str
        Name of the option without the 'with-' part i.e. passing foo will
        create a `--with-foo` and `--without-foo` options
    help : str
        Help for `cmd --help`. This should document the positive option (i.e.
        --with-foo)
    default : Optional[bool]
        The default state.

    Returns
    -------
    command : Command

    Examples
    --------
    >>> @add_with_option("foo", "Build with foo enabled", default=False)
    >>> class foobuild(build):
    >>>    def run(self):
    >>>        if self.with_foo:
    >>>            ...
A class decorator that adds a boolean --with(out)-option cmd line switch
    to a distutils.cmd.Command class
A class decorator that adds a boolean -- with ( out ) - option cmd line switch to a distutils . cmd . Command class
def add_with_option(option, help="", default=None, ):
    """
    A class decorator that adds a boolean --with(out)-option cmd line switch
    to a distutils.cmd.Command class

    Parameters
    ----------
    option : str
        Name of the option without the 'with-' part i.e. passing foo will
        create a `--with-foo` and `--without-foo` options
    help : str
        Help for `cmd --help`. This should document the positive option (i.e.
        --with-foo)
    default : Optional[bool]
        The default state.

    Returns
    -------
    command : Command

    Examples
    --------
    >>> @add_with_option("foo", "Build with foo enabled", default=False)
    >>> class foobuild(build):
    >>>    def run(self):
    >>>        if self.with_foo:
    >>>            ...

    """
    def decorator(cmdclass):
        # type: (Type[Command]) -> Type[Command]
        cmdclass.user_options = getattr(cmdclass, "user_options", []) + [
            ("with-" + option, None, help),
            ("without-" + option, None, ""),
        ]
        cmdclass.boolean_options = getattr(cmdclass, "boolean_options", []) + [
            ("with-" + option,),
        ]
        cmdclass.negative_opt = dict(
            getattr(cmdclass, "negative_opt", {}), **{
                "without-" + option: "with-" + option
            }
        )
        setattr(cmdclass, "with_" + option, default)
        return cmdclass
    return decorator
def add_with_option ( option , help = "" , default = None , ) : def decorator ( cmdclass ) : # type: (Type[Command]) -> Type[Command] cmdclass . user_options = getattr ( cmdclass , "user_options" , [ ] ) + [ ( "with-" + option , None , help ) , ( "without-" + option , None , "" ) , ] cmdclass . boolean_options = getattr ( cmdclass , "boolean_options" , [ ] ) + [ ( "with-" + option , ) , ] cmdclass . negative_opt = dict ( getattr ( cmdclass , "negative_opt" , { } ) , * * { "without-" + option : "with-" + option } ) setattr ( cmdclass , "with_" + option , default ) return cmdclass return decorator