Skip to content

Commit

Permalink
fix([email protected]): usage formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Jun 6, 2024
1 parent 4dad5c9 commit c2e95db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions cmds/cmds.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class CommandContext extends Logged {
}

async printUsageNoCommand (arg0: this) {
this.log.error('No command invoked.')
this.log.br().error('No command invoked.')
return this.printUsage(arg0)
}

Expand Down Expand Up @@ -136,27 +136,27 @@ export default class CommandContext extends Logged {
columns.name += 1
columns.sub += 2
// Display
const commands = Object.entries(commandTree)
if (commands.length < 1) {
this.log.info(`${name} defines no commands.`)
return
}
for (let [name, entry] of Object.entries(commandTree)) {
name = bold(name.padEnd(columns.name))
let args = ''
if (typeof (entry as any).args === 'string') {
args = (entry as any).args
}
args = args.padEnd(columns.args)
let sub = ''
if ((entry as any).commandTree) {
const keys = Object.keys((entry as any).commandTree)?.length ?? 0
sub = `...`
const entries = Object.entries(commandTree)
if (entries.length > 0) {
this.log.br()
for (let [name, entry] of entries) {
name = bold(name.padEnd(columns.name))
let args = ''
if (typeof (entry as any).args === 'string') {
args = (entry as any).args
}
args = args.padEnd(columns.args)
let sub = ''
if ((entry as any).commandTree) {
const keys = Object.keys((entry as any).commandTree)?.length ?? 0
sub = `...`
}
sub = sub.padStart(columns.sub).padEnd(columns.sub + 1)
this.log.info(` ${name} ${args} ${sub} ${entry.info}`)
}
sub = sub.padStart(columns.sub).padEnd(columns.sub + 1)
this.log.info(` ${name} ${args} ${sub} ${entry.info}`)
} else {
this.log.warn(`${name} defines no commands.`)
}
this.log.info()
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmds/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hackbg/cmds",
"version": "4.0.0-rc.5",
"version": "4.0.0-rc.6",
"main": "cmds.ts",
"browser": "cmds.browser.ts",
"type": "module",
Expand Down

0 comments on commit c2e95db

Please sign in to comment.