Skip to content

Commit

Permalink
fix(event-cli): improve params parsing; fix alias handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mav-rik committed May 25, 2023
1 parent ad27049 commit cbe2fd5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/event-cli/src/cli-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class WooksCli extends WooksAdapterBase {
}
this.cliHelp.addEntry({
command,
aliases: options.aliases,
aliases: options.aliases?.map(alias => alias.replace(/\\:/g, ':')), // unescape ":" character
args,
description: options.description,
examples: options.examples,
Expand Down Expand Up @@ -166,13 +166,10 @@ export class WooksCli extends WooksAdapterBase {
*/
async run(_argv?: string[]) {
const argv = _argv || process.argv.slice(2)
const firstFlagIndex = argv.findIndex((a) => a.startsWith('-')) + 1
const pathParams = firstFlagIndex
? argv.slice(0, firstFlagIndex - 1)
: argv
const pathParams = argv.filter(a => !a.startsWith('-'))
const path =
'/' +
pathParams.map((v) => encodeURI(v).replace(/\//g, '%2F')).join('/')
pathParams.map((v) => encodeURI(v).replace(/\//g, '%2F')).join('/')
const { restoreCtx, clearCtx, store } = createCliContext(
{ argv, pathParams, cliHelp: this.cliHelp, command: path.replace(/\//g, ' ').trim() },
this.mergeEventOptions(this.opts?.eventOptions)
Expand Down

0 comments on commit cbe2fd5

Please sign in to comment.