Skip to content

Commit

Permalink
CDPSDX-3111: Added version command. (#3)
Browse files Browse the repository at this point in the history
* CDPSDX-3111: Added quick version command.

Signed-off-by: Brian Towles <[email protected]>
  • Loading branch information
wonderslug authored Aug 5, 2021
1 parent a63ed2f commit 0cfe346
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cdpctl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,26 @@
###
"""CDP Control."""

import sys

import click

from cdpctl import SUPPORTED_TARGETS
from cdpctl.__version__ import __version__
from cdpctl.command import ValidateCommand
from cdpctl.command.config import render_skeleton


@click.group()
@click.group(invoke_without_command=True)
@click.option("--debug/--no-debug", default=False)
@click.option("-v", "--version", is_flag=True, default=False)
@click.pass_context
def _cli(ctx, debug=False) -> None:
def _cli(ctx, debug=False, version=False) -> None:
"""Run the cli."""
ctx.ensure_object(dict)
ctx.obj["DEBUG"] = debug
if version:
print_version()


@click.command()
Expand Down Expand Up @@ -93,6 +99,12 @@ def skeleton(output_file) -> None:
render_skeleton(output_file=output_file)


def print_version() -> None:
"""Print the cdpctl version."""
click.echo(__version__)
sys.exit(0)


config.add_command(skeleton)
_cli.add_command(validate)
_cli.add_command(config)
Expand Down

0 comments on commit 0cfe346

Please sign in to comment.