Possible cleanup of "Options" boilerplate #402

Merged
telackey merged 2 commits from erikdies/cli_ergonomics_alternatives into main 2023-05-25 00:02:25 +00:00

21
cli.py
View File

@ -14,6 +14,7 @@
# along with this program. If not, see <http:#www.gnu.org/licenses/>. # along with this program. If not, see <http:#www.gnu.org/licenses/>.
import click import click
from dataclasses import dataclass
from app import setup_repositories from app import setup_repositories
from app import build_containers from app import build_containers
@ -24,17 +25,15 @@ from app import version
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
# TODO: this seems kind of weird and heavy on boilerplate -- check it is @dataclass
# the best Python can do for us. class Options:
class Options(object): stack: str
def __init__(self, stack, quiet, verbose, dry_run, local_stack, debug, continue_on_error): quiet: bool = False
self.stack = stack verbose: bool = False
self.quiet = quiet dry_run: bool = False
self.verbose = verbose local_stack: bool = False
self.dry_run = dry_run debug: bool = False
self.local_stack = local_stack continue_on_error: bool = False
self.debug = debug
self.continue_on_error = continue_on_error
@click.group(context_settings=CONTEXT_SETTINGS) @click.group(context_settings=CONTEXT_SETTINGS)