From: DW Talton Date: Sun, 29 Mar 2020 21:15:01 +0000 (-0700) Subject: Add utils command X-Git-Tag: v0.33.0~3^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F63585%2F9;p=releng%2Flftools.git Add utils command Add utils command to hold utilities like password generators and whatnot. Issue-ID: RELENG-2754 Signed-off-by: DW Talton Change-Id: I968c73f52a87c4436c355a1b9b66a49128a3bf56 --- diff --git a/lftools/cli/__init__.py b/lftools/cli/__init__.py index fb790be9..8422bb0b 100644 --- a/lftools/cli/__init__.py +++ b/lftools/cli/__init__.py @@ -33,6 +33,7 @@ from lftools.cli.nexus import nexus from lftools.cli.rtd import rtd from lftools.cli.schema import schema from lftools.cli.sign import sign +from lftools.cli.utils import utils from lftools.cli.version import version log = logging.getLogger(__name__) @@ -92,6 +93,7 @@ cli.add_command(rtd) cli.add_command(schema) cli.add_command(lfidapi) cli.add_command(sign) +cli.add_command(utils) cli.add_command(version) try: diff --git a/lftools/cli/utils.py b/lftools/cli/utils.py new file mode 100644 index 00000000..db81ff01 --- /dev/null +++ b/lftools/cli/utils.py @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2020 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +"""lftools utils command.""" + +import click +import logging + +from lftools import helpers + +log = logging.getLogger(__name__) + + +@click.group() +@click.pass_context +def utils(ctx): + """Tools to make life easier.""" + pass + + +@click.command(name="passgen") +@click.argument("length", required=False) +@click.pass_context +def password_generator(ctx, length): + """Generate a complex password. + + Length defaults to 12 characters if not specified. + """ + if length: + log.info(helpers.generate_password(int(length))) + else: + log.info(helpers.generate_password()) + + +utils.add_command(password_generator) diff --git a/releasenotes/notes/add_util_passgen-1c2b08bbf4771c12.yaml b/releasenotes/notes/add_util_passgen-1c2b08bbf4771c12.yaml new file mode 100644 index 00000000..bc07fc38 --- /dev/null +++ b/releasenotes/notes/add_util_passgen-1c2b08bbf4771c12.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add utils section, with password generator (passgen).