24 lines
803 B
Python
24 lines
803 B
Python
# Copyright 2023 (c) Anna Schumaker.
|
|
"""A generic Command class."""
|
|
import argparse
|
|
from . import sqlite
|
|
|
|
|
|
class Command:
|
|
"""A class to help implement xfstestsdb subcommands."""
|
|
|
|
def __init__(self, subparser: argparse.Action, sql: sqlite.Connection,
|
|
name: str, help: str, **kwargs) -> None:
|
|
"""Set up the Command."""
|
|
self.parser = subparser.add_parser(name, help=help, **kwargs)
|
|
self.parser.set_defaults(function=self.do_command)
|
|
self.parser.set_defaults(done=self.do_done)
|
|
self.sql = sql
|
|
|
|
def do_command(self, args: argparse.Namespace) -> None:
|
|
"""Do something."""
|
|
raise NotImplementedError
|
|
|
|
def do_done(self, args: argparse.Namespace) -> None:
|
|
"""Run after the main command, outside of a transaction."""
|