Skip to content

Commit

Permalink
fix: generate flag comp for top-level commands
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Jan 24, 2023
1 parent 8f7672c commit 6ec795e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/commands/autocomplete/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,19 @@ compinit;\n`
})

const mainCaseBlock = () => {
// case $line[1] in
// ${mainCaseBlock()}
// esac
// ;;
let caseBlock = 'case $line[1] in\n'

for (const arg of firstArgs) {
if (!coTopics.includes(arg.id)) {
const cmd = commands.find(c=>c.id===arg.id)
if (cmd) {
caseBlock += `${arg.id})\n ${genZshFlagArgumentsBlock(cmd.flags)} ;; \n`
}
} else {
caseBlock +=`${arg.id})\n _${this.cliBin}_${arg.id} \n ;;\n`
}
}

firstArgs.forEach(arg=>{
caseBlock +=`${arg.id})\n _${this.cliBin}_${arg.id} \n ;;\n`
})
Expand Down

0 comments on commit 6ec795e

Please sign in to comment.