Skip to content

Commit

Permalink
Implement current-system in Rust.
Browse files Browse the repository at this point in the history
  • Loading branch information
noteed committed May 11, 2024
1 parent 42e0efa commit 0b5ae24
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/bin/thewithn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use clap::{Parser, Subcommand};
use std::env;
use std::fs;
use std::path::Path;

/// Thewithn single binary main entry point.
Expand Down Expand Up @@ -73,9 +74,6 @@ enum Commands {

#[derive(Parser)]
struct CurrentSystemCmd {
/// Activate verbose mode
#[arg(short, long)]
verbose: bool,
}

#[derive(Parser)]
Expand All @@ -96,11 +94,11 @@ struct DestroySystemCmd {
struct UpdateSystemCmd {
}

fn handle_current_system(args: &CurrentSystemCmd) {
if args.verbose {
println!("Called as 'current-system' with verbosity enabled.");
} else {
println!("Called as 'current-system'.");
fn handle_current_system(_args: &CurrentSystemCmd) {
let current_system_link = "/run/current-system";
match fs::read_link(current_system_link) {
Ok(path) => println!("{}", path.display()),
Err(e) => eprintln!("Failed to read link {}: {}", current_system_link, e),
}
}

Expand Down

0 comments on commit 0b5ae24

Please sign in to comment.