Comparing version
@@ -225,2 +225,6 @@ import { camelToKebab, kebabToCamel, padString } from './utils.js'; | ||
const { command, options, version } = config; | ||
// Helper to truncate with ellipsis | ||
function truncateDesc(desc, max) { | ||
return desc.length > max ? `${desc.slice(0, max - 3)}...` : desc; | ||
} | ||
// Build usage string for positionals | ||
@@ -240,5 +244,6 @@ const usagePositionals = (command.positionals ?? []) | ||
command.positionals?.forEach(arg => { | ||
console.log(` ${arg.name.padEnd(20)}${arg.description.slice(0, 65).padEnd(65)}[${arg.type || 'string'}]`); | ||
let desc = truncateDesc(arg.description, 65); | ||
desc = desc.padEnd(65); // Always pad to 65 chars for alignment | ||
console.log(` ${arg.name.padEnd(20)}${desc}[${arg.type || 'string'}]`); | ||
}); | ||
// Build usage string for options | ||
console.log('\nOptions:'); | ||
@@ -249,3 +254,5 @@ Object.keys(options).forEach(key => { | ||
const aliasStr = option.alias ? `-${option.alias}, ` : ''; | ||
console.log(` ${aliasStr.padEnd(4)}--${key.padEnd(14)}${(option.description || '').slice(0, 65).padEnd(65)}[${option.type || 'string'}]${requiredStr}`); | ||
let desc = truncateDesc(option.description || '', 65); | ||
desc = desc.padEnd(65); // Always pad to 65 chars for alignment | ||
console.log(` ${aliasStr.padEnd(4)}--${key.padEnd(14)}${desc} [${option.type || 'string'}]${requiredStr}`); | ||
}); | ||
@@ -252,0 +259,0 @@ // Print default options (help and version) |
{ | ||
"name": "cli-nano", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Mini command-line tool similar to `yargs` or `parseArgs` from Node.js that accepts positional arguments, flags and options.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -148,2 +148,3 @@ [](https://opensource.org/licenses/MIT) | ||
- [native-copyfiles](https://github.com/ghiscoding/native-copyfiles) | ||
- [native-copyfiles](https://github.com/ghiscoding/native-copyfiles) | ||
- [remove-glob](https://github.com/ghiscoding/remove-glob) |
@@ -238,2 +238,7 @@ import type { ArgumentOptions, Config } from './interfaces.js'; | ||
// Helper to truncate with ellipsis | ||
function truncateDesc(desc: string, max: number) { | ||
return desc.length > max ? `${desc.slice(0, max - 3)}...` : desc; | ||
} | ||
// Build usage string for positionals | ||
@@ -253,6 +258,7 @@ const usagePositionals = (command.positionals ?? []) | ||
command.positionals?.forEach(arg => { | ||
console.log(` ${arg.name.padEnd(20)}${arg.description.slice(0, 65).padEnd(65)}[${arg.type || 'string'}]`); | ||
let desc = truncateDesc(arg.description, 65); | ||
desc = desc.padEnd(65); // Always pad to 65 chars for alignment | ||
console.log(` ${arg.name.padEnd(20)}${desc}[${arg.type || 'string'}]`); | ||
}); | ||
// Build usage string for options | ||
console.log('\nOptions:'); | ||
@@ -263,5 +269,5 @@ Object.keys(options).forEach(key => { | ||
const aliasStr = option.alias ? `-${option.alias}, ` : ''; | ||
console.log( | ||
` ${aliasStr.padEnd(4)}--${key.padEnd(14)}${(option.description || '').slice(0, 65).padEnd(65)}[${option.type || 'string'}]${requiredStr}`, | ||
); | ||
let desc = truncateDesc(option.description || '', 65); | ||
desc = desc.padEnd(65); // Always pad to 65 chars for alignment | ||
console.log(` ${aliasStr.padEnd(4)}--${key.padEnd(14)}${desc} [${option.type || 'string'}]${requiredStr}`); | ||
}); | ||
@@ -268,0 +274,0 @@ |
Sorry, the diff of this file is not supported yet
47672
2%641
1.91%149
0.68%