Skip to content

Commit

Permalink
feat: pass in flag data to flag operator (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Apr 29, 2022
1 parent 853c582 commit 29777d4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/render-help/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,17 @@ export class Renderers {
return '<value>';
}

flagOperator() {
flagOperator(_: FlagData) {
return ' ';
}

flagName({
flag,
flagFormatted,
aliasesEnabled,
aliasFormatted,
}: FlagData) {
flagName(flagData: FlagData) {
const {
flag,
flagFormatted,
aliasesEnabled,
aliasFormatted,
} = flagData;
let flagText = '';

if (aliasFormatted) {
Expand All @@ -118,12 +119,12 @@ export class Renderers {
flagText += flagFormatted;

if ('placeholder' in flag && typeof flag.placeholder === 'string') {
flagText += `${this.flagOperator()}${flag.placeholder}`;
flagText += `${this.flagOperator(flagData)}${flag.placeholder}`;
} else {
// Test: default flag for String type short-hand
const flagPlaceholder = this.flagParameter('type' in flag ? flag.type : flag);
if (flagPlaceholder) {
flagText += `${this.flagOperator()}${flagPlaceholder}`;
flagText += `${this.flagOperator(flagData)}${flagPlaceholder}`;
}
}

Expand Down

0 comments on commit 29777d4

Please sign in to comment.