repo init

This commit is contained in:
2024-10-01 15:27:39 -05:00
commit 97d1c6c3c1
4 changed files with 80 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
use std::env;
use std::process::Command;
use std::io;
fn main() {
let os = env::consts::OS;
let arch = env::consts::ARCH;
let username = env::var("USER").unwrap_or_else(|_| "unknown".to_string());
let hostname = Command::new("hostname")
.output()
.map(|output| String::from_utf8_lossy(&output.stdout).trim().to_string())
.unwrap_or_else(|_| "unknown".to_string());
let execution_path = env::current_exe()
.map(|path| path.display().to_string())
.unwrap_or_else(|_| "unknown".to_string());
let working_directory = env::current_dir()
.map(|path| path.display().to_string())
.unwrap_or_else(|_| "unknown".to_string());
println!(
"{}@{} ({}/{}) [{}] [{}]",
username, hostname, os, arch, working_directory, execution_path
);
}