Skip to content

trestle.cli

trestle.cli ¤

Starting point for the Trestle CLI.

Attributes¤

logger = logging.getLogger('trestle') module-attribute ¤

Classes¤

Trestle ¤

Bases: CommandBase

Manage OSCAL files in a human friendly manner.

Source code in trestle/cli.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class Trestle(CommandBase):
    """Manage OSCAL files in a human friendly manner."""

    subcommands = [
        AssembleCmd,
        AuthorCmd,
        CreateCmd,
        DescribeCmd,
        HrefCmd,
        ImportCmd,
        InitCmd,
        MergeCmd,
        PartialObjectValidate,
        RemoveCmd,
        ReplicateCmd,
        SplitCmd,
        TaskCmd,
        ValidateCmd,
        VersionCmd
    ]

    # This block is uncovered as trestle cannot find plugins in it's unit tests - it is the base module.
    for plugin, cmd_cls in discovered_plugins('commands'):  # pragma: nocover
        # add commands (derived from CommandPlusDocs or CommandBase) to subcommands list
        if issubclass(cmd_cls, CommandBase):
            # don't add CommandPlusDocs or CommandBase
            if cmd_cls is not CommandPlusDocs and cmd_cls is not CommandBase:
                subcommands.append(cmd_cls)
                logger.info(f'{cmd_cls} added to subcommands from plugin {plugin}')

    def _init_arguments(self) -> None:
        self.add_argument('-v', '--verbose', help=const.DISPLAY_VERBOSE_OUTPUT, action='count', default=0)
        self.add_argument(
            '-tr', '--trestle-root', help='Path of trestle root dir', type=pathlib.Path, default=pathlib.Path.cwd()
        )
Attributes¤
subcommands = [AssembleCmd, AuthorCmd, CreateCmd, DescribeCmd, HrefCmd, ImportCmd, InitCmd, MergeCmd, PartialObjectValidate, RemoveCmd, ReplicateCmd, SplitCmd, TaskCmd, ValidateCmd, VersionCmd] class-attribute instance-attribute ¤

Functions¤

run() ¤

Run the trestle cli.

Source code in trestle/cli.py
80
81
82
83
84
85
def run() -> None:
    """Run the trestle cli."""
    log.set_global_logging_levels()
    logger.debug('Main entry point.')

    exit(Trestle().run())

handler: python