Skip to content

Commit

Permalink
Merge pull request #2 from Coder-Harshit/graphical_development
Browse files Browse the repository at this point in the history
Graphical development branch merged
  • Loading branch information
Coder-Harshit authored Jun 15, 2024
2 parents b9cb12c + a2962a6 commit 5281ff2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ authors = ["HARSHIT VIJAY"]
colored = "2.0"
sysinfo = "0.30"
whoami = "0.9"
clap = { version = "4.5", features = ["derive"] }
clap = { version = "4.5", features = ["derive"] }
6 changes: 6 additions & 0 deletions assets/logo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
___ ____ _
/ _ \/ ___| _ __ ___ ___| |_
| | | \___ \| '_ \ / _ \/ __| __|
| |_| |___) | |_) | __/ (__| |_
\___/|____/| .__/ \___|\___|\__|
|_|
23 changes: 21 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ use colored::*;
use clap::Command;
use sysinfo::{CpuRefreshKind, RefreshKind, System ,Networks};
use whoami;
use std::{env, fs};
use std::path::PathBuf;

fn get_logo_path() -> PathBuf {
let mut project_root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap_or_default());
project_root_dir.push("assets");
project_root_dir.push("logo.txt");
project_root_dir
}

fn read_logo(path: PathBuf) -> String {
fs::read_to_string(path).unwrap_or_else(|_| "Logo not found".red().to_string())}


fn format_uptime(uptime: u64) -> String {
let (secs, mins, hours, days) = (uptime % 60, (uptime / 60) % 60, (uptime / 3600) % 24, uptime / (3600 * 24));
Expand Down Expand Up @@ -58,8 +71,14 @@ fn main() {
)
.get_matches();

// Handle subcommands or default behavior

// Read ASCII logo
let logo_path = get_logo_path();
let logo = read_logo(logo_path);
println!("{}", logo); // Display the logo


// Handle subcommands or default behavior
match matches.subcommand() {
Some(("all", _)) => {
// println!("'all' subcommand used");
Expand Down Expand Up @@ -138,4 +157,4 @@ fn print_os_info() {
println!("{}: {}", "Kernel Version".blue(), sysinfo::System::kernel_version().unwrap_or_default());
println!("{}: {}", "System Uptime".blue(), format_uptime(sysinfo::System::uptime()));
// Add more OS info as needed
}
}

0 comments on commit 5281ff2

Please sign in to comment.