]> git.proxmox.com Git - proxmox-offline-mirror.git/commitdiff
use IsTerminal whenever possible
authorMaximiliano Sandoval R <m.sandoval@proxmox.com>
Fri, 17 Nov 2023 13:37:20 +0000 (14:37 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 9 Jan 2024 08:16:22 +0000 (09:16 +0100)
Continuation of https://lists.proxmox.com/pipermail/pbs-devel/2023-November/007078.html.

Signed-off-by: Maximiliano Sandoval R <m.sandoval@proxmox.com>
FG: adapted context

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/bin/proxmox-offline-mirror-helper.rs
src/bin/proxmox-offline-mirror.rs

index def10ad9d56616e2da5e2e401e67fd238e2187b5..cb6bb7bfdf98f82335dc5e1f9820096324b0a170 100644 (file)
@@ -1,3 +1,4 @@
+use std::io::IsTerminal;
 use std::path::PathBuf;
 use std::process::Command;
 use std::{collections::HashMap, path::Path};
@@ -7,8 +8,8 @@ use anyhow::{bail, format_err, Error};
 use proxmox_offline_mirror::types::Snapshot;
 use proxmox_subscription::{ProductType, SubscriptionInfo};
 use proxmox_sys::command::run_command;
+use proxmox_sys::fs::file_get_contents;
 use proxmox_sys::fs::{replace_file, CreateOptions};
-use proxmox_sys::{fs::file_get_contents, linux::tty};
 use proxmox_time::epoch_to_rfc3339_utc;
 use serde_json::Value;
 
@@ -63,7 +64,7 @@ fn set_subscription_key(
 )]
 /// Interactive setup wizard.
 async fn setup(_param: Value) -> Result<(), Error> {
-    if !tty::stdin_isatty() {
+    if !std::io::stdin().is_terminal() {
         bail!("Setup wizard can only run interactively.");
     }
 
index c645c2d10f3f31dea47a1bdbbc89dffd68c549c5..7699b4b1036761138cc48ca91cb57f7814a135c3 100644 (file)
@@ -1,4 +1,5 @@
 use std::fmt::Display;
+use std::io::IsTerminal;
 use std::matches;
 use std::path::Path;
 
@@ -11,7 +12,6 @@ use proxmox_router::cli::{run_cli_command, CliCommand, CliCommandMap, CliEnviron
 use proxmox_schema::api;
 use proxmox_section_config::SectionConfigData;
 use proxmox_subscription::ProductType;
-use proxmox_sys::linux::tty;
 
 use proxmox_offline_mirror::helpers::tty::{
     read_bool_from_tty, read_selection_from_tty, read_string_from_tty,
@@ -785,7 +785,7 @@ fn action_add_key(config: &SectionConfigData) -> Result<SubscriptionKey, Error>
 )]
 /// Interactive setup wizard.
 async fn setup(config: Option<String>, _param: Value) -> Result<(), Error> {
-    if !tty::stdin_isatty() {
+    if !std::io::stdin().is_terminal() {
         bail!("Setup wizard can only run interactively.");
     }