Showing the changes to src (2 of 3 files). Show all
Unified · Split
| @@ -90,9 +90,19 @@ pub fn main() -> Result<()> { · 89 unmodified lines | ||
| 90 | 90 | pack_path, |
| 91 | 91 | directory, |
| 92 | 92 | }) => { |
| 93 | + use gitoxide_core::pack::index::PathOrRead; | |
| 93 | 94 | let (_handle, progress) = prepare(verbose, "pack-explode", core::pack::index::PROGRESS_RANGE); |
| 95 | + let input = if let Some(path) = pack_path { | |
| 96 | + PathOrRead::Path(path) | |
| 97 | + } else { | |
| 98 | + #[cfg(feature = "atty")] | |
| 99 | + if atty::is(atty::Stream::Stdin) { | |
| 100 | + anyhow::bail!("Refusing to read from standard input as no path is given, but it's a terminal.") | |
| 101 | + } | |
| 102 | + PathOrRead::Read(Box::new(std::io::stdin())) | |
| 103 | + }; | |
| 94 | 104 | core::pack::index::from_pack( |
| 95 | − pack_path, | |
| 105 | + input, | |
| 96 | 106 | directory, |
| 97 | 107 | DoOrDiscard::from(progress), |
| 98 | 108 | core::pack::index::Context { |
| @@ -31,7 +31,6 @@ pub fn main() -> Result<()> { · 30 unmodified lines | ||
| 31 | 31 | } => { |
| 32 | 32 | let has_tips = !tips.is_empty(); |
| 33 | 33 | let has_tui = progress; |
| 34 | − #[cfg(feature = "atty")] | |
| 35 | 34 | if atty::is(if has_tui { |
| 36 | 35 | atty::Stream::Stderr |
| 37 | 36 | } else { |
| @@ -123,8 +122,17 @@ pub fn main() -> Result<()> { · 85 unmodified lines | ||
| 123 | 122 | progress_keep_open, |
| 124 | 123 | core::pack::index::PROGRESS_RANGE, |
| 125 | 124 | move |progress, out, _err| { |
| 125 | + use gitoxide_core::pack::index::PathOrRead; | |
| 126 | + let input = if let Some(path) = pack_path { | |
| 127 | + PathOrRead::Path(path) | |
| 128 | + } else { | |
| 129 | + if atty::is(atty::Stream::Stdin) { | |
| 130 | + anyhow::bail!("Refusing to read from standard input as no path is given, but it's a terminal.") | |
| 131 | + } | |
| 132 | + PathOrRead::Read(Box::new(std::io::stdin())) | |
| 133 | + }; | |
| 126 | 134 | core::pack::index::from_pack( |
| 127 | − pack_path, | |
| 135 | + input, | |
| 128 | 136 | directory, |
| 129 | 137 | git_features::progress::DoOrDiscard::from(progress), |
| 130 | 138 | core::pack::index::Context { |