style(cli): add more color
This commit is contained in:
@@ -33,6 +33,20 @@ export function createProgram(ctx: CliContext): Command {
|
|||||||
|
|
||||||
program.configureHelp({
|
program.configureHelp({
|
||||||
showGlobalOptions: true,
|
showGlobalOptions: true,
|
||||||
|
styleTitle: (t) => ctx.colors.section(t),
|
||||||
|
styleUsage: (t) => ctx.colors.description(t),
|
||||||
|
styleCommandText: (t) => ctx.colors.command(t),
|
||||||
|
styleCommandDescription: (t) => ctx.colors.muted(t),
|
||||||
|
styleOptionTerm: (t) => ctx.colors.option(t),
|
||||||
|
styleOptionText: (t) => ctx.colors.option(t),
|
||||||
|
styleOptionDescription: (t) => ctx.colors.muted(t),
|
||||||
|
styleArgumentTerm: (t) => ctx.colors.argument(t),
|
||||||
|
styleArgumentText: (t) => ctx.colors.argument(t),
|
||||||
|
styleArgumentDescription: (t) => ctx.colors.muted(t),
|
||||||
|
styleSubcommandTerm: (t) => ctx.colors.command(t),
|
||||||
|
styleSubcommandText: (t) => ctx.colors.command(t),
|
||||||
|
styleSubcommandDescription: (t) => ctx.colors.muted(t),
|
||||||
|
styleDescriptionText: (t) => ctx.colors.muted(t),
|
||||||
});
|
});
|
||||||
|
|
||||||
const collect = (value: string, previous: string[] = []): string[] => {
|
const collect = (value: string, previous: string[] = []): string[] => {
|
||||||
|
|||||||
+51
-2
@@ -190,8 +190,57 @@ export function createCliContext(normalizedArgs: string[], env: NodeJS.ProcessEn
|
|||||||
accent: wrap((t) => kleur.green(t)),
|
accent: wrap((t) => kleur.green(t)),
|
||||||
};
|
};
|
||||||
|
|
||||||
const p = (kind: Parameters<typeof statusPrefix>[0]): string => statusPrefix(kind, output);
|
const p = (kind: Parameters<typeof statusPrefix>[0]): string => {
|
||||||
const l = (kind: Parameters<typeof labelPrefix>[0]): string => labelPrefix(kind, output);
|
const prefix = statusPrefix(kind, output);
|
||||||
|
if (output.plain || !output.color) {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
if (kind === 'ok') {
|
||||||
|
return kleur.green(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'warn') {
|
||||||
|
return kleur.yellow(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'err') {
|
||||||
|
return kleur.red(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'info') {
|
||||||
|
return kleur.cyan(prefix);
|
||||||
|
}
|
||||||
|
return kleur.gray(prefix);
|
||||||
|
};
|
||||||
|
|
||||||
|
const l = (kind: Parameters<typeof labelPrefix>[0]): string => {
|
||||||
|
const prefix = labelPrefix(kind, output);
|
||||||
|
if (output.plain || !output.color) {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
if (kind === 'url') {
|
||||||
|
return kleur.cyan(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'date') {
|
||||||
|
return kleur.magenta(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'source') {
|
||||||
|
return kleur.gray(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'engine') {
|
||||||
|
return kleur.blue(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'credentials') {
|
||||||
|
return kleur.yellow(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'user') {
|
||||||
|
return kleur.cyan(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'userId') {
|
||||||
|
return kleur.magenta(prefix);
|
||||||
|
}
|
||||||
|
if (kind === 'email') {
|
||||||
|
return kleur.green(prefix);
|
||||||
|
}
|
||||||
|
return kleur.gray(prefix);
|
||||||
|
};
|
||||||
|
|
||||||
const config = loadConfig((message) => {
|
const config = loadConfig((message) => {
|
||||||
console.error(colors.muted(`${p('warn')}${message}`));
|
console.error(colors.muted(`${p('warn')}${message}`));
|
||||||
|
|||||||
Reference in New Issue
Block a user