help-text-formatter
Scannednpx machina-cli add skill a5c-ai/babysitter/help-text-formatter --openclawFiles (1)
SKILL.md
5.6 KB
Help Text Formatter
Generate formatted, user-friendly help text for CLI applications.
Capabilities
- Generate structured help text layouts
- Create command examples with descriptions
- Format options and arguments sections
- Implement custom help formatters
- Add color and styling support
- Generate man page compatible output
Usage
Invoke this skill when you need to:
- Create consistent help text formatting
- Add examples to command help
- Implement custom help renderers
- Generate documentation from help text
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| language | string | Yes | Target language (typescript, python, go) |
| commands | array | Yes | Command definitions with help text |
| styling | object | No | Color and formatting options |
Command Structure
{
"commands": [
{
"name": "deploy",
"description": "Deploy application to target environment",
"longDescription": "Deploy the application with optional configuration...",
"arguments": [
{ "name": "service", "description": "Service to deploy" }
],
"options": [
{ "flags": "-e, --env", "description": "Target environment" }
],
"examples": [
{ "command": "deploy api -e production", "description": "Deploy API to production" }
]
}
]
}
Generated Patterns
TypeScript Help Formatter
import chalk from 'chalk';
interface HelpSection {
title: string;
content: string | string[];
}
export function formatHelp(command: CommandDefinition): string {
const sections: HelpSection[] = [];
// Description
sections.push({
title: '',
content: command.description,
});
// Usage
sections.push({
title: 'Usage',
content: ` $ ${command.name} ${formatUsage(command)}`,
});
// Arguments
if (command.arguments?.length) {
sections.push({
title: 'Arguments',
content: command.arguments.map(arg =>
` ${chalk.cyan(arg.name.padEnd(20))} ${arg.description}`
),
});
}
// Options
if (command.options?.length) {
sections.push({
title: 'Options',
content: command.options.map(opt =>
` ${chalk.cyan(opt.flags.padEnd(20))} ${opt.description}`
),
});
}
// Examples
if (command.examples?.length) {
sections.push({
title: 'Examples',
content: command.examples.map(ex =>
` ${chalk.dim('$')} ${ex.command}\n ${chalk.dim(ex.description)}`
),
});
}
return renderSections(sections);
}
function renderSections(sections: HelpSection[]): string {
return sections.map(section => {
const title = section.title
? chalk.bold.underline(section.title) + '\n\n'
: '';
const content = Array.isArray(section.content)
? section.content.join('\n')
: section.content;
return title + content;
}).join('\n\n');
}
Python Help Formatter
from typing import List, Optional
import textwrap
class HelpFormatter:
def __init__(self, width: int = 80, indent: int = 2):
self.width = width
self.indent = ' ' * indent
def format_command(self, command: dict) -> str:
sections = []
# Description
sections.append(command['description'])
# Usage
usage = self._format_usage(command)
sections.append(f"Usage:\n{self.indent}{usage}")
# Arguments
if args := command.get('arguments'):
section = self._format_section('Arguments', args)
sections.append(section)
# Options
if opts := command.get('options'):
section = self._format_section('Options', opts)
sections.append(section)
# Examples
if examples := command.get('examples'):
section = self._format_examples(examples)
sections.append(section)
return '\n\n'.join(sections)
def _format_section(self, title: str, items: List[dict]) -> str:
lines = [f"{title}:"]
for item in items:
name = item.get('name') or item.get('flags', '')
desc = item.get('description', '')
lines.append(f"{self.indent}{name:<20} {desc}")
return '\n'.join(lines)
def _format_examples(self, examples: List[dict]) -> str:
lines = ["Examples:"]
for ex in examples:
lines.append(f"{self.indent}$ {ex['command']}")
lines.append(f"{self.indent} {ex['description']}")
lines.append('')
return '\n'.join(lines).rstrip()
def _format_usage(self, command: dict) -> str:
parts = [command['name']]
for arg in command.get('arguments', []):
if arg.get('required', True):
parts.append(f"<{arg['name']}>")
else:
parts.append(f"[{arg['name']}]")
parts.append('[options]')
return ' '.join(parts)
Workflow
- Analyze commands - Review command definitions
- Structure sections - Organize help content
- Format content - Apply styling and layout
- Add examples - Include usage examples
- Generate output - Create final help text
Best Practices Applied
- Consistent section ordering
- Appropriate indentation
- Color coding for clarity
- Example-driven documentation
- Terminal width awareness
- Screen reader friendly
Target Processes
- cli-documentation-generation
- argument-parser-setup
- cli-command-structure-design
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/help-text-formatter/SKILL.mdView on GitHub Overview
Generates consistent, user-friendly help text for CLI apps. It supports sections like Description, Usage, Arguments, Options, and Examples, with color styling and man-page compatible output.
How This Skill Works
The formatter ingests a command schema (name, description, arguments, options, examples) and renders a multi-section help layout for TypeScript, Python, or Go. It applies optional styling and color, then outputs sections such as Description, Usage, Arguments, Options, and Examples, mirroring the patterns shown in the TypeScript and Python renderers.
When to Use It
- You need a consistent, reusable help layout across multiple CLI commands.
- You want to add practical command examples to improve user understanding.
- You're building or integrating a custom help renderer for a project.
- You need documentation-ready help text that can feed into docs or man pages.
- You are targeting multiple languages (TypeScript, Python, Go) and want uniform formatting.
Quick Start
- Step 1: Define command schema (name, description, arguments, options, examples).
- Step 2: Choose target language (TypeScript, Python, Go) and an optional styling object.
- Step 3: Run the formatter to produce structured help text and render it.
Best Practices
- Define a clear, concise description for each command.
- Document all arguments and options with precise descriptions.
- Include representative examples for common use cases.
- Keep the Usage line concise and readable; prefer straightforward layouts.
- Test generated output for readability and compatibility with man-page style.
Example Use Cases
- Format help for a deploy command that includes an --env option and a longDescription.
- Generate a help block with Usage, Arguments, and Options for a build tool.
- Render a colored Examples section to illustrate sample commands.
- Produce a man-page compatible output for a CLI utility.
- Implement a custom help formatter to match branding across projects.
Frequently Asked Questions
Add this skill to your agents