Skip to content

Commit 27045c6

Browse files
added quiet flag (#167)
1 parent 9d7f2f1 commit 27045c6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/box-command.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,9 @@ class BoxCommand extends Command {
779779
* @returns {void}
780780
*/
781781
info(content) {
782-
process.stderr.write(`${content}${os.EOL}`);
782+
if (!this.flags.quiet) {
783+
process.stderr.write(`${content}${os.EOL}`);
784+
}
783785
}
784786

785787
/**
@@ -1131,12 +1133,17 @@ BoxCommand.flags = {
11311133
char: 'y',
11321134
description: 'Automatically respond yes to all confirmation prompts',
11331135
}),
1136+
quiet: flags.boolean({
1137+
char: 'q',
1138+
description: 'Suppress any non-error output to stderr',
1139+
})
11341140
};
11351141

11361142
BoxCommand.minFlags = _.pick(BoxCommand.flags, [
11371143
'no-color',
11381144
'help',
1139-
'verbose'
1145+
'verbose',
1146+
'quiet'
11401147
]);
11411148

11421149
module.exports = BoxCommand;

test/commands/files.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ describe('Files', () => {
243243
assert.equal(ctx.stderr, `Deleted file ${fileId}${os.EOL}`);
244244
});
245245

246+
test
247+
.nock(TEST_API_ROOT, api => api
248+
.delete(`/2.0/files/${fileId}`)
249+
.reply(204)
250+
)
251+
.stderr()
252+
.command([
253+
'files:delete',
254+
fileId,
255+
'--quiet',
256+
'--token=test',
257+
])
258+
.it('should delete a file, but output no information to stderr', ctx => {
259+
assert.equal(ctx.stderr, '');
260+
});
261+
246262
test
247263
.nock(TEST_API_ROOT, api => api
248264
.delete(`/2.0/files/${fileId}`)

0 commit comments

Comments
 (0)