circle-exclamation
Deeplint is still in the MVP development phase and not yet available for use.

UI Module

The UI module provides a set of components and utilities for creating a consistent and user-friendly command-line interface. This document provides an overview of the UI module and how to use it.

Overview

The UI module is designed to provide a consistent visual language across the CLI, making it easier to create a polished and professional user experience. It includes:

  • Theme System: A centralized theme system that defines colors, typography, symbols, and spacing.

  • Enhanced Logger: An enhanced logger that uses the theme system to create visually appealing log messages.

  • Interactive Elements: Spinners, progress bars, and interactive prompts for better user interaction.

  • Command Output Enhancements: Banners, tables, and JSON output for better command output.

Getting Started

To use the UI module, import it in your code:

import * as ui from "../ui";

Theme System

The theme system provides a consistent visual language across the CLI. It includes:

Colors

The theme system defines a set of colors for different purposes:

Symbols

The theme system defines a set of symbols for different message types:

Typography

The theme system defines a set of typography styles for consistent text formatting:

Spacing

The theme system defines a set of spacing constants for consistent layout:

Utility Functions

The theme system provides utility functions for common tasks:

Enhanced Logger

The enhanced logger provides a more visually appealing and structured logging experience. It includes:

Basic Logging

Error Logging with Context

Grouped Logs

Collapsed Groups

Indented Groups

JSON Output

Log Levels

Best Practices

Use the Theme System

Always use the theme system to ensure a consistent visual language across the CLI. This makes it easier to maintain and update the UI in the future.

Use the Enhanced Logger

Use the enhanced logger for all logging to ensure a consistent logging experience. The enhanced logger provides better formatting, support for structured output, and log levels.

Use log groups to organize related logs. This makes it easier to understand the structure of the output.

Use Appropriate Log Levels

Use the appropriate log level for each message. This allows users to control the verbosity of the output.

Spinner Component

The spinner component provides a loading indicator for long-running operations. It uses the oraarrow-up-right library for the actual spinner implementation.

Basic Usage

Spinner Options

Spinner Methods

Static Methods

Helper Functions

Progress Bar Component

The progress bar component provides a visual indicator for tracking progress in long-running operations. It uses the cli-progressarrow-up-right library for the actual progress bar implementation.

Basic Usage

Progress Bar Options

Progress Bar Methods

Processing Arrays

Multiple Progress Bars

Interactive Prompts Component

The interactive prompts component provides a set of utilities for creating interactive prompts in the CLI. It uses the @clack/promptsarrow-up-right library for the actual prompt implementation.

Basic Usage

Helper Functions

The interactive prompts component provides several helper functions for common prompt types:

Text Input

Password Input

Confirmation

Select

Multi-select

Notes

Task with Spinner

Cancellation

Session Management

The banner component provides a way to display headers and messages in the CLI. It uses the boxenarrow-up-right library for creating boxes around text.

Basic Usage

App Banner

Command Banner

Themed Banners

Custom Padding and Margin

Table Component

The table component provides a way to display structured data in the CLI. It uses a custom implementation that's designed to be robust and handle edge cases gracefully.

Basic Usage

Table Options

Table Styles

Creating Tables from Data

Formatting Tables as Strings

Error Handling

The table component is designed to handle edge cases gracefully:

  • Empty or null data

  • Missing or malformed headers

  • ANSI color codes in cell content

  • Varying row lengths

  • Null or undefined cell values

Best Practices

  1. Always provide explicit headers when possible to ensure consistent table structure:

  1. Handle potential null/undefined values in your data before passing to the table:

  1. Use try/catch blocks when displaying tables with potentially problematic data:

Future Enhancements

The UI module will be enhanced with additional components in the future:

  • JSON Output: For programmatic consumption

Last updated