Skip to content

Commit

Permalink
Add --silent option
Browse files Browse the repository at this point in the history
  • Loading branch information
danburzo committed Aug 13, 2024
1 parent c46d84b commit ccf84cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ Trimd accepts one or more input files, or uses the standard input (`stdin`) when
A couple of general options are available:
- **`-h, --help`** - output help information
- **`-v, --version`** - output program version
- **`-h, --help`** - output help information.
- **`-v, --version`** - output program version.
- **`--silent`** - suppress the output of commands.
By default, the results of processing the operands are concatenated to `stdout`. Use the `--write` option to write the results back to their respective original files.
Expand Down
12 changes: 9 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const args = opsh(process.argv.slice(2), [
'v',
'version',
'data-url',
'write'
'write',
'silent'
]);

const [command, ...operands] = args.operands;
Expand Down Expand Up @@ -146,12 +147,14 @@ const results = await Promise.all(
if (args.options.write) {
operands.forEach((operand, idx) => {
if (operand === '-') {
console.warn('Using --write, `stdin` skipped.');
if (!args.options.silent) {
console.warn('Using --write, `stdin` skipped.');
}
return;
}
writeFile(operand, results[idx]);
});
} else {
} else if (!args.options.silent) {
console.log(results.join('\n'));
}

Expand Down Expand Up @@ -185,6 +188,9 @@ General options:
outputting to 'stdout'. When using --write,
the result of processing 'stdin' is ignored.
--silent
Suppress the output of commands.
Commands:
markdown
Expand Down

0 comments on commit ccf84cc

Please sign in to comment.