Add Runtime::input_is_pipe()

We need this because we might want to check whether we can get the STDIN
handle from the runtime or not.
In some (rare) cases, the runtime "thinks" that STDIN is a stream of
IDs, but it is not. So the client can check whether stdin is a pipe
(thus, whether Runtime thinks that there's a stream of IDs) and easily
work around that by taking ::std::io::stdin() itself.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-11-09 13:29:20 +01:00
parent 7b6e5eafba
commit 01db294700

View file

@ -336,10 +336,6 @@ impl<'a> Runtime<'a> {
&self.cli_matches
}
pub fn ids_from_stdin(&self) -> bool {
self.has_input_pipe
}
pub fn ids<T: IdPathProvider>(&self) -> Result<Option<Vec<StoreId>>> {
use std::io::Read;
@ -410,6 +406,16 @@ impl<'a> Runtime<'a> {
self.has_output_pipe
}
pub fn input_is_pipe(&self) -> bool {
self.has_input_pipe
}
/// Alias for Runtime::input_is_pipe()
pub fn ids_from_stdin(&self) -> bool {
self.input_is_pipe()
}
/// Check whether the runtime ignores touched ids
///
/// "Ignoring" in this context means whether the runtime prints them or not.