Skip to content

Commit

Permalink
Colorize CLI commands usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfontaine committed Apr 5, 2024
1 parent 9103e7c commit a5ddf50
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 8 deletions.
19 changes: 18 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ requests-toolbelt = "1.0.0"
requests = "2.31.0"
rich = "13.7.1"
xlsxwriter = "3.2.0"
click-help-colors = "^0.9.4"

[tool.poetry.group.dev.dependencies]
coverage = { extras = ["toml"], version = "^7.4.4" }
Expand Down
8 changes: 7 additions & 1 deletion spacemk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ccl
import click
from benedict import benedict
from click_help_colors import HelpColorsGroup
from dotenv import load_dotenv
from envyaml import EnvYAML
from icecream import ic
Expand All @@ -14,7 +15,12 @@
debug_enabled = False


@click.group(help="Helper to move from various tools to Spacelift.")
@click.group(
cls=HelpColorsGroup,
help="Helper to move from various tools to Spacelift.",
help_headers_color="yellow",
help_options_color="green",
)
@click.option(
"--config",
default="config.yml",
Expand Down
8 changes: 7 additions & 1 deletion spacemk/commands/audit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import click
from click.decorators import pass_meta_key
from click_help_colors import HelpColorsCommand

from spacemk.exporters import load_exporter


@click.command(help="Audit the source vendor setup.")
@click.command(
cls=HelpColorsCommand,
help="Audit the source vendor setup.",
help_headers_color="yellow",
help_options_color="green",
)
@pass_meta_key("config")
def audit(config):
exporter = load_exporter(config=config.get("exporter", {}))
Expand Down
8 changes: 7 additions & 1 deletion spacemk/commands/create_module_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import click
import requests
from click_help_colors import HelpColorsCommand
from requests_toolbelt.utils import dump as request_dump

from spacemk import load_normalized_data
Expand Down Expand Up @@ -31,7 +32,12 @@ def _get_repository_tags(endpoint: str, github_api_token: str, namespace: str, r
return data


@click.command(help="Create module versions.")
@click.command(
cls=HelpColorsCommand,
help="Create module versions.",
help_headers_color="yellow",
help_options_color="green",
)
@click.decorators.pass_meta_key("config")
def create_module_versions(config):
data = load_normalized_data()
Expand Down
8 changes: 7 additions & 1 deletion spacemk/commands/export.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import click
from click.decorators import pass_meta_key
from click_help_colors import HelpColorsCommand

from spacemk.exporters import load_exporter


@click.command(help="Export information from the source vendor.")
@click.command(
cls=HelpColorsCommand,
help="Export information from the source vendor.",
help_headers_color="yellow",
help_options_color="green",
)
@pass_meta_key("config")
def export(config):
exporter = load_exporter(config=config.get("exporter", {}))
Expand Down
8 changes: 7 additions & 1 deletion spacemk/commands/generate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import click
from click_help_colors import HelpColorsCommand

from spacemk.generator import Generator


@click.command(help="Generate Terraform code to manage Spacelift entities.")
@click.command(
cls=HelpColorsCommand,
help="Generate Terraform code to manage Spacelift entities.",
help_headers_color="yellow",
help_options_color="green",
)
def generate():
generator = Generator()
generator.generate()
8 changes: 7 additions & 1 deletion spacemk/commands/set_sensitive_env_vars.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import click
from click.decorators import pass_meta_key
from click_help_colors import HelpColorsCommand

from spacemk.spacelift import Spacelift


@click.command(help="Set sensitive environment variable values in Spacelift.")
@click.command(
cls=HelpColorsCommand,
help="Set sensitive environment variable values in Spacelift.",
help_headers_color="yellow",
help_options_color="green",
)
@pass_meta_key("config")
def set_sensitive_env_vars(config):
spacelift = Spacelift(config.get("spacelift"))
Expand Down
8 changes: 7 additions & 1 deletion spacemk/commands/set_tf_vars_with_invalid_name.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import click
from click.decorators import pass_meta_key
from click_help_colors import HelpColorsCommand

from spacemk.spacelift import Spacelift


@click.command(help="Set value of Terraform variable with invalid name in Spacelift.")
@click.command(
cls=HelpColorsCommand,
help="Set value of Terraform variable with invalid name in Spacelift.",
help_headers_color="yellow",
help_options_color="green",
)
@pass_meta_key("config")
def set_tf_vars_with_invalid_name(config):
spacelift = Spacelift(config.get("spacelift"))
Expand Down

0 comments on commit a5ddf50

Please sign in to comment.