bktide
Version:
Command-line interface for Buildkite CI/CD workflows with rich shell completions (Fish, Bash, Zsh) and Alfred workflow integration for macOS power users
46 lines • 2.03 kB
JavaScript
import { BaseFormatter } from './Formatter.js';
import { renderTable } from '../../ui/table.js';
import { isMobileTerminal } from '../../ui/responsive-table.js';
import { SEMANTIC_COLORS, formatEmptyState } from '../../ui/theme.js';
export class PlainTextFormatter extends BaseFormatter {
name = 'plain-text';
formatOrganizations(organizations, _options) {
if (!organizations || organizations.length === 0) {
return formatEmptyState('No organizations found', [
'Check your API token has the correct permissions',
'Run "bktide token --check" to verify your access'
]);
}
const lines = [];
if (isMobileTerminal()) {
// For very narrow terminals, use a vertical list format
organizations.forEach((org, i) => {
if (i > 0)
lines.push(''); // Separator between items
lines.push(SEMANTIC_COLORS.heading(org.name || 'Unknown'));
lines.push(` ${SEMANTIC_COLORS.label('Slug:')} ${org.slug || '-'}`);
});
}
else {
// Build table with enhanced headers
const rows = [];
// Bold + underlined headers for emphasis
const headers = ['NAME', 'SLUG'].map(h => SEMANTIC_COLORS.heading(h));
rows.push(headers);
organizations.forEach((org) => {
rows.push([
org.name || SEMANTIC_COLORS.muted('-'),
org.slug || SEMANTIC_COLORS.muted('-')
]);
});
lines.push(renderTable(rows, { preserveWidths: true }));
}
// Add summary line (dimmed)
lines.push('');
lines.push(SEMANTIC_COLORS.dim(organizations.length === 1
? '1 organization accessible'
: `${SEMANTIC_COLORS.count(organizations.length.toString())} organizations accessible`));
return lines.join('\n');
}
}
//# sourceMappingURL=PlainTextFormatter.js.map