Skip to content

Commit

Permalink
feat(cli): add verbose (vb) flag that can control output of all file … (
Browse files Browse the repository at this point in the history
#74)

* feat(cli): add verbose (vb) flag that can control output of all file paths to console

* docs(README): add -vb description
  • Loading branch information
seangwright authored and biesbjerg committed Nov 7, 2017
1 parent 8d1e2c5 commit 14eb09f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -93,3 +93,5 @@ Options:
[boolean] [default: false]
--clean, -c Remove obsolete strings when merging
[boolean] [default: false]
--verbose, -vb If true, prints all processed file paths to console
[boolean] [default: true]
6 changes: 6 additions & 0 deletions src/cli/cli.ts
Expand Up @@ -82,6 +82,12 @@ export const cli = yargs
default: false,
type: 'boolean'
})
.option('verbose', {
alias: 'vb',
describe: 'Log all output to console',
default: true,
type: 'boolean'
})
.exitProcess(true)
.parse(process.argv);

Expand Down
6 changes: 4 additions & 2 deletions src/cli/tasks/extract.task.ts
Expand Up @@ -14,6 +14,7 @@ export interface ExtractTaskOptionsInterface {
sort?: boolean;
clean?: boolean;
patterns?: string[];
verbose?: boolean;
}

export class ExtractTask implements TaskInterface {
Expand All @@ -22,7 +23,8 @@ export class ExtractTask implements TaskInterface {
replace: false,
sort: false,
clean: false,
patterns: []
patterns: [],
verbose: true
};

protected _parsers: ParserInterface[] = [];
Expand Down Expand Up @@ -64,7 +66,7 @@ export class ExtractTask implements TaskInterface {
let collection: TranslationCollection = new TranslationCollection();
this._input.forEach(dir => {
this._readDir(dir, this._options.patterns).forEach(path => {
this._out(chalk.gray('- %s'), path);
this._options.verbose && this._out(chalk.gray('- %s'), path);
const contents: string = fs.readFileSync(path, 'utf-8');
this._parsers.forEach((parser: ParserInterface) => {
collection = collection.union(parser.extract(contents, path));
Expand Down

0 comments on commit 14eb09f

Please sign in to comment.