Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical development #2

Merged
merged 4 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.23"
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::{NetworkExt, ProcessorExt, System, SystemExt};
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 main() {
let mut system = System::new_all();
Expand Down Expand Up @@ -30,8 +43,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 @@ -92,4 +111,4 @@ fn print_os_info(system: &mut System) {
println!("{}: {}", "OS Name".blue(), system.name().unwrap_or_default());
println!("{}: {}", "Kernel Version".blue(), system.kernel_version().unwrap_or_default());
// Add more OS info as needed
}
}