Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on atty #280

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Removed the dependency on `num_cpus` in favor of `std::thread::available_parallelism`. [#279](https://github.com/jonhoo/inferno/pull/279)
- Removed the dependency on `atty` in favor of `is_terminal`. [#280](https://github.com/jonhoo/inferno/pull/280)

## [0.11.14] - 2023-01-21
### Added
Expand Down
163 changes: 152 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nameattr = ["indexmap"]

[dependencies]
ahash = "0.8"
atty = "0.2"
is-terminal = "0.4.3"
crossbeam-utils = { version = "0.8", optional = true }
crossbeam-channel = { version = "0.5", optional = true }
dashmap = { version = "5", optional = true }
Expand Down
3 changes: 2 additions & 1 deletion src/bin/diff-folded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::PathBuf;
use clap::{ArgAction, Parser};
use env_logger::Env;
use inferno::differential::{self, Options};
use is_terminal::IsTerminal;

#[derive(Debug, Parser)]
#[clap(
Expand Down Expand Up @@ -88,7 +89,7 @@ fn main() -> io::Result<()> {

let (folded1, folded2, options) = opt.into_parts();

if atty::is(atty::Stream::Stdout) {
if std::io::stdout().is_terminal() {
differential::from_files(options, folded1, folded2, io::stdout().lock())
} else {
differential::from_files(
Expand Down
3 changes: 2 additions & 1 deletion src/bin/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use inferno::flamegraph::{self, defaults, Direction, Options, Palette, TextTrunc

#[cfg(feature = "nameattr")]
use inferno::flamegraph::FuncFrameAttrsMap;
use is_terminal::IsTerminal;

#[derive(Debug, Parser)]
#[clap(name = "inferno-flamegraph", about)]
Expand Down Expand Up @@ -332,7 +333,7 @@ fn main() -> quick_xml::Result<()> {

options.palette_map = palette_map.as_mut();

if atty::is(atty::Stream::Stdout) {
if std::io::stdout().is_terminal() {
flamegraph::from_files(&mut options, &infiles, io::stdout().lock())?;
} else {
flamegraph::from_files(
Expand Down
4 changes: 3 additions & 1 deletion src/collapse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub mod vtune;
/// [crate-level documentation]: ../../index.html
pub mod vsprof;

use is_terminal::IsTerminal;

// DEFAULT_NTHREADS is public because we use it in the help text of the binaries,
// but it doesn't need to be exposed to library users, hence #[doc(hidden)].
#[doc(hidden)]
Expand Down Expand Up @@ -100,7 +102,7 @@ pub trait Collapse {
where
P: AsRef<Path>,
{
if atty::is(atty::Stream::Stdout) {
if std::io::stdout().is_terminal() {
self.collapse_file(infile, io::stdout().lock())
} else {
self.collapse_file(infile, io::BufWriter::new(io::stdout().lock()))
Expand Down