ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

pass -v to ssh on --verbose (#407)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

marshmallow
autofix-ci[bot]
and committed by
GitHub
5bf0da88 5439d792

+66 -52
+4
CHANGELOG.md
··· 7 7 8 8 ## [Unreleased] - yyyy-mm-dd 9 9 10 + ### Added 11 + 12 + - `--verbose` will pass `-v` to SSH commands. 13 + 10 14 ## [v1.2.0] - 2026-03-18 11 15 12 16 ### Added
+1 -1
Cargo.lock
··· 260 260 checksum = "9d92b1fab272fe943881b77cc6e920d6543e5b1bfadbd5ed81c7c5a755742394" 261 261 dependencies = [ 262 262 "clap", 263 - "log", 263 + "tracing-core", 264 264 ] 265 265 266 266 [[package]]
+3 -1
Cargo.toml
··· 18 18 [workspace.dependencies] 19 19 futures-util = { version = "0.3.31", features = ["sink", "std"] } 20 20 clap = { version = "4.5.51", features = ["derive", "string", "cargo"] } 21 - clap-verbosity-flag = "3.0.4" 21 + clap-verbosity-flag = { version = "3.0.4", features = [ 22 + "tracing", 23 + ], default-features = false } 22 24 serde = { version = "1.0.228", features = ["derive", "rc"] } 23 25 tokio = { version = "1.48.0", features = ["full"] } 24 26 tracing = { version = "0.1.41", features = ["release_max_level_debug"] }
+2
crates/cli/src/cli.rs
··· 9 9 use clap_num::number_range; 10 10 use clap_verbosity_flag::InfoLevel; 11 11 use tokio::runtime::Handle; 12 + use tracing::level_filters::LevelFilter; 12 13 use wire_core::SubCommandModifiers; 13 14 use wire_core::commands::common::get_hive_node_names; 14 15 use wire_core::hive::node::{ ··· 332 333 } 333 334 _ => wire_core::StrictHostKeyChecking::default(), 334 335 }, 336 + verbose: self.verbose.tracing_level_filter() > LevelFilter::INFO, 335 337 } 336 338 } 337 339 }
+1 -2
crates/cli/src/tracing_setup.rs
··· 10 10 use clap_verbosity_flag::{LogLevel, Verbosity}; 11 11 use owo_colors::{OwoColorize, Stream, Style}; 12 12 use tracing::{Level, Subscriber}; 13 - use tracing_log::AsTrace; 14 13 use tracing_subscriber::{ 15 14 Layer, 16 15 field::{RecordFields, VisitFmt}, ··· 252 251 /// Set up logging for the application 253 252 /// Uses `WireFieldFormat` if -v was never passed 254 253 pub fn setup_logging<L: LogLevel>(verbosity: &Verbosity<L>, show_progress: bool) { 255 - let filter = verbosity.log_level_filter().as_trace(); 254 + let filter = verbosity.tracing_level_filter(); 256 255 let registry = tracing_subscriber::registry(); 257 256 258 257 STATUS.lock().show_progress(show_progress);
+53 -48
crates/core/src/hive/node.rs
··· 91 91 92 92 options.extend(["BatchMode=yes".to_string()]); 93 93 94 + if modifiers.verbose { 95 + vector.push("-v".to_string()); 96 + } 97 + 94 98 vector.push("-o".to_string()); 95 99 vector.extend(options.into_iter().intersperse("-o".to_string())); 96 100 ··· 326 330 use super::*; 327 331 use std::{assert_matches::assert_matches, env}; 328 332 329 - #[test] 330 - fn test_ssh_opts() { 333 + fn setup_ssh_opts_test() -> (Target, String) { 331 334 let target = Target::from_host("hello-world"); 332 - let subcommand_modifiers = SubCommandModifiers { 333 - non_interactive: false, 334 - ..Default::default() 335 - }; 336 335 let tmp = format!( 337 336 "/tmp/{}", 338 337 rand::distr::SampleString::sample_string(&Alphabetic, &mut rand::rng(), 10) 339 338 ); 339 + std::fs::create_dir(&tmp).unwrap(); 340 + unsafe { env::set_var("XDG_RUNTIME_DIR", &tmp) }; 341 + (target, tmp) 342 + } 340 343 341 - std::fs::create_dir(&tmp).unwrap(); 344 + #[test] 345 + fn test_ssh_opts_verbose() { 346 + let (target, _tmp) = setup_ssh_opts_test(); 342 347 343 - unsafe { env::set_var("XDG_RUNTIME_DIR", &tmp) } 348 + let args = target 349 + .create_ssh_args(SubCommandModifiers { 350 + verbose: true, 351 + ..Default::default() 352 + }) 353 + .unwrap(); 354 + 355 + assert!( 356 + args.contains(&"-v".to_string()), 357 + "Verbose flag should add -v to SSH args" 358 + ); 344 359 345 - let args = [ 360 + let expected = vec![ 346 361 "-l".to_string(), 347 362 target.user.to_string(), 348 363 "-p".to_string(), 349 364 target.port.to_string(), 365 + "-v".to_string(), 350 366 "-o".to_string(), 351 367 "StrictHostKeyChecking=accept-new".to_string(), 352 368 "-o".to_string(), 353 369 "BatchMode=yes".to_string(), 354 370 ]; 371 + assert_eq!(args, expected); 372 + } 355 373 356 - assert_eq!(target.create_ssh_args(subcommand_modifiers).unwrap(), args); 357 - assert_eq!( 358 - target.create_ssh_opts(subcommand_modifiers).unwrap(), 359 - args.join(" ") 360 - ); 374 + #[test] 375 + fn test_ssh_opts_non_interactive() { 376 + let (target, _tmp) = setup_ssh_opts_test(); 361 377 362 - assert_eq!( 363 - target.create_ssh_args(subcommand_modifiers).unwrap(), 364 - [ 365 - "-l".to_string(), 366 - target.user.to_string(), 367 - "-p".to_string(), 368 - target.port.to_string(), 369 - "-o".to_string(), 370 - "StrictHostKeyChecking=accept-new".to_string(), 371 - "-o".to_string(), 372 - "BatchMode=yes".to_string(), 373 - ] 374 - ); 378 + let default_args = target 379 + .create_ssh_args(SubCommandModifiers::default()) 380 + .unwrap(); 381 + 382 + let non_interactive_args = target 383 + .create_ssh_args(SubCommandModifiers { 384 + non_interactive: true, 385 + ..Default::default() 386 + }) 387 + .unwrap(); 375 388 376 389 assert_eq!( 377 - target.create_ssh_args(subcommand_modifiers).unwrap(), 378 - [ 379 - "-l".to_string(), 380 - target.user.to_string(), 381 - "-p".to_string(), 382 - target.port.to_string(), 383 - "-o".to_string(), 384 - "StrictHostKeyChecking=accept-new".to_string(), 385 - "-o".to_string(), 386 - "BatchMode=yes".to_string(), 387 - ] 390 + default_args, non_interactive_args, 391 + "non_interactive flag should not affect SSH args" 388 392 ); 389 393 390 - // forced non interactive is the same as --non-interactive 391 - assert_eq!( 392 - target.create_ssh_args(subcommand_modifiers).unwrap(), 393 - target 394 - .create_ssh_args(SubCommandModifiers { 395 - non_interactive: true, 396 - ..Default::default() 397 - }) 398 - .unwrap() 399 - ); 394 + let expected = vec![ 395 + "-l".to_string(), 396 + target.user.to_string(), 397 + "-p".to_string(), 398 + target.port.to_string(), 399 + "-o".to_string(), 400 + "StrictHostKeyChecking=accept-new".to_string(), 401 + "-o".to_string(), 402 + "BatchMode=yes".to_string(), 403 + ]; 404 + assert_eq!(default_args, expected); 400 405 } 401 406 402 407 #[test]
+2
crates/core/src/lib.rs
··· 43 43 pub show_trace: bool, 44 44 pub non_interactive: bool, 45 45 pub ssh_accept_host: StrictHostKeyChecking, 46 + pub verbose: bool, 46 47 } 47 48 48 49 impl Default for SubCommandModifiers { ··· 51 52 show_trace: false, 52 53 non_interactive: !std::io::stdin().is_terminal(), 53 54 ssh_accept_host: StrictHostKeyChecking::default(), 55 + verbose: false, 54 56 } 55 57 } 56 58 }