diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4732c24 --- /dev/null +++ b/install.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +function makeDirectories() { + echo "Creating required directories..." + + if [ ! -d "/usr/share/ponyfetch" ]; then + mkdir /usr/share/ponyfetch + mkdir /usr/share/ponyfetch/ponies + fi +} + +function compile() { + echo "Compiling ponyfetch..." + + if [ ! -f "/usr/bin/ponyfetch" ]; then + cargo build --release + fi +} + +function moveFiles() { + echo "Moving files..." + + if [ ! -f "/usr/bin/ponyfetch" ]; then + cp target/release/ponyfetch /usr/bin/ponyfetch + fi + + toCopyCount=$(ls -1 /usr/share/ponyfetch/ponies/*.txt 2>/dev/null | wc -l) + dirCount=$(ls -1 ponies/*.txt 2>/dev/null | wc -l) + + if [ $toCopyCount != $dirCount ]; then + cp -r ponies/* /usr/share/ponyfetch/ponies + fi +} + +echo "Thanks for choosing ponyfetch!" +echo "Let's begin installing!" + +makeDirectories +compile +moveFiles \ No newline at end of file diff --git a/ponies/mcintosh_large.txt b/ponies/mcintosh_large.txt index a3993dd..6223457 100644 --- a/ponies/mcintosh_large.txt +++ b/ponies/mcintosh_large.txt @@ -12,10 +12,10 @@ / .'-'''':/ _\.-- \ '.\ )\ ( y' -`| /-.-\ \ .'`-. ) \ \( ( (((:.:)) \ '. `-.-' ) - '. |\( \\\_// '. '. .-'`| - ''.` \``` . '. `-'` / - \ \__. /'. .' - -' / .' ( '-.-' + '. |\( \\\_// '. '. .-'`| + ''.` \``` . '. `-'` / + \ \__. /'. .' + -' / .' ( '-.-' | ,' .| | ( .' / (.' \ \ | ( ( \ \ diff --git a/src/helpers/colors.rs b/src/helpers/colors.rs index bbffca9..7a425a8 100644 --- a/src/helpers/colors.rs +++ b/src/helpers/colors.rs @@ -36,10 +36,7 @@ const COLORS : [(&str, &str); 34] = [ ]; pub fn print(text: &str, inline: bool, color: &str) { - let mut color = color; - if color == "rainbowdash" { - color = "bright_magenta"; - } + let color = color; let color = color; let color = COLORS.iter().find(|(name, _)| name == &color).unwrap().1; diff --git a/src/helpers/mod.rs b/src/helpers/mod.rs index dc90cec..669692b 100644 --- a/src/helpers/mod.rs +++ b/src/helpers/mod.rs @@ -1,3 +1,4 @@ pub mod file; pub mod colors; -pub mod print; \ No newline at end of file +pub mod print; +pub mod paths; \ No newline at end of file diff --git a/src/helpers/paths.rs b/src/helpers/paths.rs new file mode 100644 index 0000000..090854d --- /dev/null +++ b/src/helpers/paths.rs @@ -0,0 +1,16 @@ +use std::path::PathBuf; + +#[cfg(target_os = "linux")] +pub fn get_pony_path() -> String { + if std::env::current_exe().unwrap().to_str().unwrap().contains("target") { + PathBuf::from("ponies/") + .to_str() + .unwrap() + .to_string() + } else { + PathBuf::from("/usr/share/ponyfetch/ponies/") + .to_str() + .unwrap() + .to_string() + } +} \ No newline at end of file diff --git a/src/helpers/print.rs b/src/helpers/print.rs index 2a2983d..f1edae0 100644 --- a/src/helpers/print.rs +++ b/src/helpers/print.rs @@ -45,7 +45,7 @@ pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str) } pub fn print_ponyline(line: u16, pony: &str, color: &str) { - file_open(&format!("ponies/{}.txt", pony).to_string()) + file_open(&format!("{}{}.txt", helpers::paths::get_pony_path(), pony).to_string()) .lines() .skip(line as usize) .take(1) diff --git a/src/main.rs b/src/main.rs index 9d9663b..4aa8832 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,7 +87,7 @@ fn main() { let args: Args = Args::parse(); let line_count = helpers::file::get_file_linecount( - &format!("ponies/{}.txt", &args.pony) + &format!("{}{}.txt", helpers::paths::get_pony_path(), &args.pony) ); let to_skip = ((line_count / 2) as f32).floor() - 6.0;