Exemple #1
0
def test_add_command_names(builder):
    server = CommandName("server")
    add = CommandName("add")

    builder.add_command_names(server, add)

    assert [server, add] == builder.get_command_names()
Exemple #2
0
def test_set_command_names(builder):
    builder.add_command_name(CommandName("cluster"))

    server = CommandName("server")
    add = CommandName("add")

    builder.set_command_names(server, add)

    assert [server, add] == builder.get_command_names()
Exemple #3
0
def test_get_command_names_with_base_definition(base_format_builder):
    server = CommandName("server")
    add = CommandName("add")

    base_format_builder.add_command_name(server)

    builder = ArgsFormatBuilder(base_format_builder.format)
    builder.add_command_name(add)

    assert [server, add] == builder.get_command_names()
    assert [add] == builder.get_command_names(False)
Exemple #4
0
def test_has_command_names_with_base_definition(base_format_builder):
    base_format_builder.add_command_name(CommandName("server"))

    builder = ArgsFormatBuilder(base_format_builder.format)

    assert builder.has_command_names()
    assert not builder.has_command_names(False)

    builder.add_command_name(CommandName("add"))

    assert builder.has_command_names()
    assert builder.has_command_names(False)
Exemple #5
0
def test_has_command_names(builder):
    assert not builder.has_command_names()
    assert not builder.has_command_names(False)

    builder.add_command_name(CommandName("cluster"))

    assert builder.has_command_names()
    assert builder.has_command_names(False)
    def build_args_format(
            self,
            base_format=None):  # type: (Optional[ArgsFormat]) -> ArgsFormat
        builder = ArgsFormatBuilder(base_format)

        if not self._anonymous:
            builder.add_command_name(CommandName(self.name, self.aliases))

        builder.add_options(*self.options.values())
        builder.add_arguments(*self.arguments.values())

        return builder.format