Skip to content

Commit

Permalink
fix(cli): fix double output, fix #1291
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Dec 11, 2023
1 parent 7f1f0e9 commit d88c8db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/koishi/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const cli = CAC('koishi').help().version(version)

registerStartCommand(cli)

cli.parse()
const argv = cli.parse()

if (!cli.matchedCommand) {
if (!cli.matchedCommand && !argv.options.help) {
cli.outputHelp()
}
4 changes: 1 addition & 3 deletions packages/koishi/src/cli/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,12 @@ export default function (cli: CAC) {
.option('--debug [namespace]', 'specify debug namespace')
.option('--log-level [level]', 'specify log level (default: 2)')
.option('--log-time [format]', 'show timestamp in logs')
.option('--watch [path]', 'watch and reload at change')
.action((file, options) => {
const { logLevel, debug, logTime, watch, ...rest } = options
const { logLevel, debug, logTime, ...rest } = options
if (logLevel !== undefined && (!isInteger(logLevel) || logLevel < 0)) {
console.warn(`${kleur.red('error')} log level should be a positive integer.`)
process.exit(1)
}
setEnvArg('KOISHI_WATCH_ROOT', watch) // for backward compatibility
setEnvArg('KOISHI_LOG_TIME', logTime)
process.env.KOISHI_LOG_LEVEL = logLevel || ''
process.env.KOISHI_DEBUG = debug || ''
Expand Down

0 comments on commit d88c8db

Please sign in to comment.