Skip to content

Commit 7a7625a

Browse files
Mossakaclaude
andauthored
feat(cli): organize help text with logical option groups (#1241)
Reorganize CLI options into logical groups (Domain Filtering, Image Management, Container Configuration, Network & Security, API Proxy, Logging & Debug) with a custom help formatter that inserts section headers. Shorten verbose option descriptions for readability. Fixes #500 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ffc1746 commit 7a7625a

File tree

2 files changed

+213
-81
lines changed

2 files changed

+213
-81
lines changed

src/cli.test.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command } from 'commander';
2-
import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, parseMemoryLimit, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, validateApiTargetInAllowedDomains, DEFAULT_OPENAI_API_TARGET, DEFAULT_ANTHROPIC_API_TARGET, emitApiProxyTargetWarnings } from './cli';
2+
import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, parseMemoryLimit, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, validateApiTargetInAllowedDomains, DEFAULT_OPENAI_API_TARGET, DEFAULT_ANTHROPIC_API_TARGET, emitApiProxyTargetWarnings, formatItem, program } from './cli';
33
import { redactSecrets } from './redact-secrets';
44
import * as fs from 'fs';
55
import * as path from 'path';
@@ -1732,4 +1732,55 @@ describe('cli', () => {
17321732
});
17331733
});
17341734

1735+
describe('formatItem', () => {
1736+
it('should format item with description on same line when term fits', () => {
1737+
const result = formatItem('-v', 'verbose output', 20, 2, 2, 80);
1738+
expect(result).toBe(' -v verbose output');
1739+
});
1740+
1741+
it('should format item with description on next line when term is long', () => {
1742+
const result = formatItem('--very-long-option-name-here', 'desc', 10, 2, 2, 80);
1743+
expect(result).toContain('--very-long-option-name-here');
1744+
expect(result).toContain('\n');
1745+
expect(result).toContain('desc');
1746+
});
1747+
1748+
it('should format item without description', () => {
1749+
const result = formatItem('--flag', '', 20, 2, 2, 80);
1750+
expect(result).toBe(' --flag');
1751+
});
1752+
});
1753+
1754+
describe('help text formatting', () => {
1755+
it('should include section headers in help output', () => {
1756+
const help = program.helpInformation();
1757+
expect(help).toContain('Domain Filtering:');
1758+
expect(help).toContain('Image Management:');
1759+
expect(help).toContain('Container Configuration:');
1760+
expect(help).toContain('Network & Security:');
1761+
expect(help).toContain('API Proxy:');
1762+
expect(help).toContain('Logging & Debug:');
1763+
});
1764+
1765+
it('should include usage line', () => {
1766+
const help = program.helpInformation();
1767+
expect(help).toContain('Usage: awf');
1768+
});
1769+
1770+
it('should include program description', () => {
1771+
const help = program.helpInformation();
1772+
expect(help).toContain('Network firewall for agentic workflows');
1773+
});
1774+
1775+
it('should include arguments section', () => {
1776+
const help = program.helpInformation();
1777+
expect(help).toContain('Arguments:');
1778+
});
1779+
1780+
it('should include options section', () => {
1781+
const help = program.helpInformation();
1782+
expect(help).toContain('Options:');
1783+
});
1784+
});
1785+
17351786
});

0 commit comments

Comments
 (0)