# Path: fimfarchive/commands/base.py
# class Command(ABC):
#     """
#     Command line interface for tasks.
#     """
# 
#     @abstractmethod
#     def __call__(self, *args: str) -> int:
#         """
#         Runs the command.
# 
#         Args:
#             *args: Command line arguments.
# 
#         Returns:
#             Application exit status.
# 
#         Raises:
#             SystemExit: If the arguments are invalid.
#         """
# 
# Path: fimfarchive/commands/root.py
# class RootCommand(Command):
#     """
#     The main application command.
#     """
#     commands: Dict[str, Type[Command]] = {
#         'build': BuildCommand,
#         'update': UpdateCommand,
#     }
# 
#     def load(self, command: str) -> Command:
#         """
#         Instantiates a command.
# 
#         Args:
#             command: Name of the command to instantiate.
# 
#         Returns:
#             An instance of the specified command.
# 
#         Raises:
#             KeyError: If the command does not exist.
#         """
#         return self.commands[command]()
# 
#     def doc(self, command: str, adjust=1, indent=2) -> str:
#         """
#         Generates documentation for a single command.
# 
#         Args:
#             command: Name of the command to document.
#             adjust: Number of spaces before the command summary.
#             indent: Number of spaces before the command name.
# 
#         Returns:
#             A name and summary for the command.
#         """
#         cls = self.load(command)
#         doc = getattr(cls, '__doc__', None)
# 
#         if doc:
#             doc = str(doc).strip()
#             doc = doc.split('\n', 1)[0]
# 
#         description = [
#             indent * ' ',
#             command.ljust(adjust),
#             str(doc),
#         ]
# 
#         return ''.join(description)
# 
#     @property
#     def usage(self) -> str:
#         """
#         Generates a list of the available commands.
# 
#         Returns:
#             A usage help text for the application.
#         """
#         text = [
#             'Usage: COMMAND [PARAMETERS]\n\n',
#             'Fimfarchive, ensuring that history is preseved.\n\n',
#         ]
# 
#         if not self.commands:
#             return ''.join(text).strip()
# 
#         commands = sorted(cmd for cmd in self.commands.keys())
#         adjust = max(len(cmd) for cmd in commands) + 2
# 
#         text.append('Commands:\n')
#         for command in commands:
#             line = self.doc(command, adjust)
#             text.extend((line, '\n'))
# 
#         return ''.join(text).strip()
# 
#     def __call__(self, *args: str) -> int:
#         try:
#             cmd = self.load(args[0])
#         except (IndexError, KeyError):
#             exit(self.usage)
#         else:
#             return cmd(*args[1:])


from unittest.mock import MagicMock, PropertyMock
from fimfarchive.commands import Command, RootCommand
import pytest
        Command that returns 0.

        With a truncated documentation line.
        """
        __call__ = MagicMock(return_value=0)

    return cls()


@pytest.fixture
def failure():
    """
    Returns a command that fails.
    """
    class cls(Command):
        """
        Command that returns 1.

        With a truncated documentation line.
        """
        __call__ = MagicMock(return_value=1)

    return cls()


@pytest.fixture
def root(success, failure):
    """
    Returns a root command with custom subcommands.
    """

# Path: fimfarchive/commands/base.py
# class Command(ABC):
#     """
#     Command line interface for tasks.
#     """
# 
#     @abstractmethod
#     def __call__(self, *args: str) -> int:
#         """
#         Runs the command.
# 
#         Args:
#             *args: Command line arguments.
# 
#         Returns:
#             Application exit status.
# 
#         Raises:
#             SystemExit: If the arguments are invalid.
#         """
# 
# Path: fimfarchive/commands/root.py
# class RootCommand(Command):
#     """
#     The main application command.
#     """
#     commands: Dict[str, Type[Command]] = {
#         'build': BuildCommand,
#         'update': UpdateCommand,
#     }
# 
#     def load(self, command: str) -> Command:
#         """
#         Instantiates a command.
# 
#         Args:
#             command: Name of the command to instantiate.
# 
#         Returns:
#             An instance of the specified command.
# 
#         Raises:
#             KeyError: If the command does not exist.
#         """
#         return self.commands[command]()
# 
#     def doc(self, command: str, adjust=1, indent=2) -> str:
#         """
#         Generates documentation for a single command.
# 
#         Args:
#             command: Name of the command to document.
#             adjust: Number of spaces before the command summary.
#             indent: Number of spaces before the command name.
# 
#         Returns:
#             A name and summary for the command.
#         """
#         cls = self.load(command)
#         doc = getattr(cls, '__doc__', None)
# 
#         if doc:
#             doc = str(doc).strip()
#             doc = doc.split('\n', 1)[0]
# 
#         description = [
#             indent * ' ',
#             command.ljust(adjust),
#             str(doc),
#         ]
# 
#         return ''.join(description)
# 
#     @property
#     def usage(self) -> str:
#         """
#         Generates a list of the available commands.
# 
#         Returns:
#             A usage help text for the application.
#         """
#         text = [
#             'Usage: COMMAND [PARAMETERS]\n\n',
#             'Fimfarchive, ensuring that history is preseved.\n\n',
#         ]
# 
#         if not self.commands:
#             return ''.join(text).strip()
# 
#         commands = sorted(cmd for cmd in self.commands.keys())
#         adjust = max(len(cmd) for cmd in commands) + 2
# 
#         text.append('Commands:\n')
#         for command in commands:
#             line = self.doc(command, adjust)
#             text.extend((line, '\n'))
# 
#         return ''.join(text).strip()
# 
#     def __call__(self, *args: str) -> int:
#         try:
#             cmd = self.load(args[0])
#         except (IndexError, KeyError):
#             exit(self.usage)
#         else:
#             return cmd(*args[1:])


# Path: tests/commands/test_root.py
from unittest.mock import MagicMock, PropertyMock
from fimfarchive.commands import Command, RootCommand
import pytest

        Command that returns 0.

        With a truncated documentation line.
        """
        __call__ = MagicMock(return_value=0)

    return cls()


@pytest.fixture
def failure():
    """
    Returns a command that fails.
    """
    class cls(Command):
        """
        Command that returns 1.

        With a truncated documentation line.
        """
        __call__ = MagicMock(return_value=1)

    return cls()


@pytest.fixture
def root(success, failure):
    """
    Returns a root command with custom subcommands.
    """

    class cls(RootCommand):