mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-01-22 00:04:31 +03:00
Replace atty with stdlib
is_terminal() is part of rust 1.70 std, no need for isatty Signed-off-by: Alexander Fougner <fougner89@gmail.com>
This commit is contained in:
parent
bc0a443850
commit
a95a25dc1d
41
Cargo.lock
generated
41
Cargo.lock
generated
@ -27,9 +27,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
|
||||
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
@ -65,17 +65,6 @@ version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@ -87,7 +76,6 @@ name = "bcachefs-tools"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"atty",
|
||||
"bch_bindgen",
|
||||
"byteorder",
|
||||
"clap",
|
||||
@ -224,9 +212,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.4.8"
|
||||
version = "4.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eaf7dcb7c21d8ca1a2482ee0f1d341f437c9a7af6ca6da359dc5e1b164e98215"
|
||||
checksum = "abb745187d7f4d76267b37485a65e0149edd0e91a4cfcdd3f27524ad86cee9f3"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
@ -314,15 +302,6 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.9"
|
||||
@ -355,9 +334,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@ -482,9 +461,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a"
|
||||
checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@ -526,9 +505,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.30"
|
||||
version = "0.38.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
|
||||
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"errno 0.3.8",
|
||||
|
@ -10,7 +10,6 @@ name = "bcachefs"
|
||||
path = "src/bcachefs.rs"
|
||||
|
||||
[dependencies]
|
||||
atty = "0.2.14"
|
||||
log = { version = "0.4", features = ["std"] }
|
||||
colored = "2"
|
||||
clap = { version = "4.0.32", features = ["derive", "wrap_help"] }
|
||||
|
@ -1,4 +1,3 @@
|
||||
use atty::Stream;
|
||||
use log::{error};
|
||||
use bch_bindgen::bcachefs;
|
||||
use bch_bindgen::opt_set;
|
||||
@ -9,6 +8,7 @@ use bch_bindgen::btree::BtreeIter;
|
||||
use bch_bindgen::btree::BtreeNodeIter;
|
||||
use bch_bindgen::btree::BtreeIterFlags;
|
||||
use clap::{Parser};
|
||||
use std::io::{stdout, IsTerminal};
|
||||
|
||||
fn list_keys(fs: &Fs, opt: Cli) -> anyhow::Result<()> {
|
||||
let trans = BtreeTrans::new(fs);
|
||||
@ -117,7 +117,7 @@ pub struct Cli {
|
||||
fsck: bool,
|
||||
|
||||
/// Force color on/off. Default: autodetect tty
|
||||
#[arg(short, long, action = clap::ArgAction::Set, default_value_t=atty::is(Stream::Stdout))]
|
||||
#[arg(short, long, action = clap::ArgAction::Set, default_value_t=stdout().is_terminal())]
|
||||
colorize: bool,
|
||||
|
||||
/// Verbose mode
|
||||
|
@ -1,8 +1,8 @@
|
||||
use atty::Stream;
|
||||
use bch_bindgen::{bcachefs, bcachefs::bch_sb_handle, opt_set};
|
||||
use log::{info, debug, error, LevelFilter};
|
||||
use clap::{Parser};
|
||||
use uuid::Uuid;
|
||||
use std::io::{stdout, IsTerminal};
|
||||
use std::path::PathBuf;
|
||||
use crate::key;
|
||||
use crate::key::KeyLocation;
|
||||
@ -150,7 +150,7 @@ pub struct Cli {
|
||||
options: String,
|
||||
|
||||
/// Force color on/off. Default: autodetect tty
|
||||
#[arg(short, long, action = clap::ArgAction::Set, default_value_t=atty::is(Stream::Stdout))]
|
||||
#[arg(short, long, action = clap::ArgAction::Set, default_value_t=stdout().is_terminal())]
|
||||
colorize: bool,
|
||||
|
||||
/// Verbose mode
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::io::{stdin, IsTerminal};
|
||||
|
||||
use log::{info};
|
||||
use bch_bindgen::bcachefs::bch_sb_handle;
|
||||
use clap::builder::PossibleValue;
|
||||
@ -86,11 +88,11 @@ fn ask_for_key(sb: &bch_sb_handle) -> anyhow::Result<()> {
|
||||
|
||||
let bch_key_magic = BCH_KEY_MAGIC.as_bytes().read_u64::<LittleEndian>().unwrap();
|
||||
let crypt = sb.sb().crypt().unwrap();
|
||||
let pass = if atty::is(atty::Stream::Stdin) {
|
||||
let pass = if stdin().is_terminal() {
|
||||
rpassword::prompt_password("Enter passphrase: ")?
|
||||
} else {
|
||||
let mut line = String::new();
|
||||
std::io::stdin().read_line(&mut line)?;
|
||||
stdin().read_line(&mut line)?;
|
||||
line
|
||||
};
|
||||
let pass = std::ffi::CString::new(pass.trim_end())?; // bind to keep the CString alive
|
||||
|
Loading…
Reference in New Issue
Block a user