Skip to content

Commit

Permalink
[ts] move flag values parser out of flag declaration because of type …
Browse files Browse the repository at this point in the history
…issues
  • Loading branch information
grasword committed Sep 25, 2023
1 parent 0813281 commit 85d2821
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions source/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ export default class Validate extends Command {

static override flags = {
path: Flags.string({ char: 'p', summary: 'path to translation folder', default: process.cwd() }),
rules: Flags.string({
char: 'r',
summary: 'list of rules to run',
parse: async (input) => {
let rules = input.split(', ')
if (rules.length === 1) {
rules = input.split(',')
}
return rules
}
})
rules: Flags.string({ char: 'r', summary: 'list of rules to run' })
}

public async run(): Promise<void> {
const { flags } = await this.parse(Validate)

const parseFlags = (input: string): string[] => {
let rules = input.split(', ')
if (rules.length === 1) {
rules = input.split(',')
}
return rules
}

const translator = initTranslator(flags.path)
const validator = await initValidator(translator, flags.rules)
const validator = await initValidator(translator, parseFlags(flags.rules))

const report = JSON.stringify(validator.run())

this.log(validator.run())
this.log(report)
}
}

0 comments on commit 85d2821

Please sign in to comment.