Skip to content

Commit

Permalink
feat: add --quiet option to riw app translate
Browse files Browse the repository at this point in the history
  • Loading branch information
avaragado committed Apr 12, 2018
1 parent a37a74b commit e3754ae
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/bin/commands/app-commands/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ export const builder = (yyargs: yargs.Argv) => yyargs
Your riw configuration settings determine how riw looks for message descriptors,
and where the final files are saved. See configuration documentation for details.
`);
`)
.options({
quiet: {
alias: 'q',
boolean: true,
group: 'Command options',
desc: outdent`
Output nothing
`,
},
});

const sfrelFromFabsFromConfig = (config: Config) => (fabs: AbsolutePath) =>
chalk.green(path.relative(config.rootDir, fabs));
Expand All @@ -42,7 +52,11 @@ const squashToLength = (ctCharMax: number) => (str: string) => (
: str
);

export const handler = createHandlerWithRIW((riw: RIW) => {
const makeAppTranslateSpec: (RIW, boolean) => AppTranslateSpec = (riw, quiet) => {
if (quiet) {
return {};
}

// $FlowFixMe flow moans at process.stdout.columns, no idea how to fix
const ctCharLine = process.stdout.columns;
const sfrelFromFabs = sfrelFromFabsFromConfig(riw.config);
Expand All @@ -54,7 +68,7 @@ export const handler = createHandlerWithRIW((riw: RIW) => {
let ctMD = 0;
let bar = bardot.widthBar((ctCharLine / 2) - 10); // leave room for ctMD

const opt: AppTranslateSpec = {
return {
on: {
start: () => {
spinner.text = {
Expand Down Expand Up @@ -129,6 +143,10 @@ export const handler = createHandlerWithRIW((riw: RIW) => {
},
},
};
};

export const handler = createHandlerWithRIW((riw: RIW, argv: yargs.Argv) => {
const opt = makeAppTranslateSpec(riw, argv.quiet);

try {
riw.app.translate(opt);
Expand Down

0 comments on commit e3754ae

Please # to comment.