How to use invoke - 10 common examples

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 / executor.py View on Github external
def subcollection_config_works_with_default_tasks(self):
            @task(default=True)
            def mytask(c):
                assert c.my_key == "value"

            # Sets up a task "known as" sub.mytask which may be called as
            # just 'sub' due to being default.
            sub = Collection("sub", mytask=mytask)
            sub.configure({"my_key": "value"})
            main = Collection(sub=sub)
            # Execute via collection default 'task' name.
            Executor(collection=main).execute("sub")
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)