UI Layer¶
Command-line interface and user interaction components.
CLI¶
Command-line interface for Skim keyboard layout image generator.
This module provides the CLI entry points for the skim tool using Click. It defines the main command group and subcommands for generating keymap images and configuration files.
- Commands:
skim generate: Generate keymap visualization imagesskim configure: Generate or output configuration files
Example
Generate images from a keymap file:
$ skim generate --keymap layout.kbi --output-dir ./images
Generate with custom configuration:
$ skim -v INFO generate -k layout.vil -c config.yaml -f png
Create configuration from Keybard file:
$ skim configure -k layout.kbi -o skim-config.yaml
Read keymap from stdin:
$ cat keymap.json | skim generate - -o ./out
- class skim.ui.cli.AliasedGroup(name=None, commands=None, invoke_without_command=False, no_args_is_help=None, subcommand_metavar=None, chain=False, result_callback=None, **kwargs)[source]¶
Bases:
GroupClick Group that supports command name abbreviation.
Allows users to invoke commands using unique prefixes instead of full command names. For example,
skim genmatchesgenerateif no other command starts with “gen”.Example
$ skim gen –keymap foo.kbi # Matches ‘generate’ $ skim conf -k bar.kbi # Matches ‘configure’
- Parameters:
Logging Configuration¶
Logging configuration for Skim CLI output.
This module provides logging setup with colored output and emoji indicators for different log levels. The configuration is optimized for CLI usage with progress feedback and debug information.
- Log level formatting:
DEBUG: Green with bug emoji (🐞)
INFO: Normal with contextual emoji (from record.emoji)
WARNING: Yellow with warning emoji (⚠️)
ERROR/CRITICAL: Red with error emoji (🚨)
Example
>>> from skim.ui.logging_config import setup_logging
>>> setup_logging("INFO", quiet=False)
>>> import logging
>>> logger = logging.getLogger(__name__)
>>> logger.info("Processing...", extra={"emoji": "🔄"})
🔄 Processing...
- class skim.ui.logging_config.ColoredFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]¶
Bases:
FormatterCustom log formatter with ANSI colors and emoji support.
Applies color coding based on log level and prepends optional emoji indicators to log messages. The emoji can be specified per-record using the “emoji” extra field.
- ANSI color codes are used for terminal output:
DEBUG: Green
INFO: Default (reset)
WARNING: Yellow
ERROR+: Red
- GREY¶
ANSI code for grey text.
- GREEN¶
ANSI code for green text.
- YELLOW¶
ANSI code for yellow text.
- RED¶
ANSI code for red text.
- BOLD_RED¶
ANSI code for bold red text.
- BLUE¶
ANSI code for blue text.
- RESET¶
ANSI code to reset formatting.
Example
>>> formatter = ColoredFormatter() >>> handler.setFormatter(formatter)
- GREY = '\x1b[38;5;240m'¶
- GREEN = '\x1b[32m'¶
- YELLOW = '\x1b[33m'¶
- RED = '\x1b[31m'¶
- BOLD_RED = '\x1b[31;1m'¶
- BLUE = '\x1b[34m'¶
- RESET = '\x1b[0m'¶
- skim.ui.logging_config.setup_logging(verbosity, quiet)[source]¶
Configure the logging system for CLI output.
Sets up the root logger with colored output to stderr. The verbosity level can be specified as a string matching standard logging levels.
- Parameters:
- Return type:
Example
>>> setup_logging("INFO", quiet=False) >>> logging.info("This will be shown")
>>> setup_logging("WARNING", quiet=False) >>> logging.info("This will NOT be shown")
>>> setup_logging("DEBUG", quiet=True) >>> logging.debug("This will NOT be shown (quiet=True)")