Skip to content

Commit 2c13290

Browse files
committed
Return an error for modes still not supported when operating on stdin.
1 parent aff15e5 commit 2c13290

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/bin/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ pub enum OperationError {
7777
/// supported.
7878
#[fail(display = "The `--check` option is not supported with standard input.")]
7979
CheckWithStdin,
80+
/// Attempt to use --emit with a mode which is not currently
81+
/// supported with stdandard input.
82+
#[fail(display = "Emit mode {} not supported with standard output.", _0)]
83+
StdinBadEmit(EmitMode),
8084
}
8185

8286
impl From<IoError> for OperationError {
@@ -249,6 +253,16 @@ fn format_string(input: String, options: GetOptsOptions) -> Result<i32, FailureE
249253
if options.check {
250254
return Err(OperationError::CheckWithStdin.into());
251255
}
256+
match options.emit_mode {
257+
// Emit modes which work with standard input
258+
// None means default, which is Stdout.
259+
None |
260+
Some(EmitMode::Stdout) |
261+
Some(EmitMode::Json) => {}
262+
Some(emit_mode) => {
263+
return Err(OperationError::StdinBadEmit(emit_mode).into());
264+
},
265+
}
252266
// emit mode is always Stdout for Stdin.
253267
config
254268
.set()

0 commit comments

Comments
 (0)