mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-02 19:32:25 +01:00
Remove Input.as_file and add Input::stdin_as_file
This commit is contained in:
16
src/input.rs
16
src/input.rs
@@ -125,6 +125,17 @@ impl<'a> Input<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stdin_as_file(name: Option<impl AsRef<OsStr>>) -> Self {
|
||||
match name {
|
||||
None => Input::stdin(),
|
||||
Some(name) => {
|
||||
let mut input = Input::stdin().with_name(Some(name.as_ref()));
|
||||
input.description.kind = Some("File".to_owned());
|
||||
input
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_reader(reader: Box<dyn Read + 'a>) -> Self {
|
||||
let kind = InputKind::CustomReader(reader);
|
||||
Input {
|
||||
@@ -152,11 +163,6 @@ impl<'a> Input<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn as_file(mut self, provided_name: Option<&OsStr>) -> Self {
|
||||
self.description.kind = Some("File".to_owned());
|
||||
self.with_name(provided_name)
|
||||
}
|
||||
|
||||
pub fn description(&self) -> &InputDescription {
|
||||
&self.description
|
||||
}
|
||||
|
Reference in New Issue
Block a user