How to use the invoke.parser.Argument function in invoke

To help you get started, we’ve selected a few invoke examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyinvoke / invoke / tests / parser / parser.py View on Github external
def returned_arguments_not_given_contain_default_values(self):
            # I.e. a Context with args A and B, invoked with no mention of B,
            # should result in B existing in the result, with its default value
            # intact, and not e.g. None, or the arg not existing.
            a = Argument('name', kind=str)
            b = Argument('age', default=7)
            c = Context('mytask', args=(a, b))
            Parser((c,)).parse_argv(['mytask', '--name', 'blah'])
            eq_(c.args['age'].value, 7)
github pyinvoke / invoke / tests / parser_argument.py View on Github external
def may_validate_on_set(self):
            with raises(ValueError):
                Argument("a", kind=int).value = "five"
github pyinvoke / invoke / tests / parser_argument.py View on Github external
def can_declare_positional(self):
            assert Argument(name="foo", positional=True).positional is True
github pyinvoke / invoke / tests / parser / parser.py View on Github external
def no_ambiguity_with_flaglike_value_if_option_val_was_given(self):
                p = self._parser((
                    Argument('foo', optional=True),
                    Argument('bar', kind=bool)
                ))
                # This should NOT raise a ParseError.
                result = self._parse("--foo hello --bar", p)
                eq_(result[0].args['foo'].value, 'hello')
                eq_(result[0].args['bar'].value, True)
github pyinvoke / invoke / tests / parser_argument.py View on Github external
def defaults_to_str(self):
            assert Argument("a").kind == str
github pyinvoke / invoke / tests / parser_argument.py View on Github external
def bool_implies_no_value_needed(self):
            assert not Argument(name="a", kind=bool).takes_value
github pyinvoke / invoke / tests / parser / parser.py View on Github external
def _basic(self):
                arg = Argument('pos', positional=True)
                mytask = Context(name='mytask', args=[arg])
                return Parser(contexts=[mytask])
github pyinvoke / invoke / tests / parser_parser.py View on Github external
def invalid_flaglike_value_is_stored_as_value(self):
                self._parser((Argument("foo", optional=True),))
                result = self._parse("--foo --bar")
                assert result[0].args["foo"].value == "--bar"
github pyinvoke / invoke / tests / parser_parser.py View on Github external
def unfilled_posargs(self):
                p = self._parser(
                    (
                        Argument("foo", optional=True),
                        Argument("bar", positional=True),
                    )
                )
                self._test_for_ambiguity("--foo uhoh", p)
github pyinvoke / invoke / invoke / program.py View on Github external
.. versionadded:: 1.0
        """
        # Arguments pertaining specifically to invocation as 'invoke' itself
        # (or as other arbitrary-task-executing programs, like 'fab')
        return [
            Argument(
                names=("collection", "c"),
                help="Specify collection name to load.",
            ),
            Argument(
                names=("no-dedupe",),
                kind=bool,
                default=False,
                help="Disable task deduplication.",
            ),
            Argument(
                names=("search-root", "r"),
                help="Change root directory used for finding task modules.",
            ),