mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-30 07:37:59 +01:00
feat: 🎸 Add install.sh script
This commit is contained in:
parent
8fd7c9b1a2
commit
efa52c72d3
7 changed files with 65 additions and 11 deletions
40
install.sh
Executable file
40
install.sh
Executable file
|
@ -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
|
|
@ -12,10 +12,10 @@
|
|||
/ .'-'''':/ _\.-- \ '.\ )\
|
||||
( y' -`| /-.-\ \ .'`-. ) \
|
||||
\( ( (((:.:)) \ '. `-.-' )
|
||||
'. |\( \\\_// '. '. .-'`|
|
||||
''.` \``` . '. `-'` /
|
||||
\ \__. /'. .'
|
||||
-' / .' ( '-.-'
|
||||
'. |\( \\\_// '. '. .-'`|
|
||||
''.` \``` . '. `-'` /
|
||||
\ \__. /'. .'
|
||||
-' / .' ( '-.-'
|
||||
| ,' .| | (
|
||||
.' / (.' \ \
|
||||
| ( ( \ \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
pub mod file;
|
||||
pub mod colors;
|
||||
pub mod print;
|
||||
pub mod print;
|
||||
pub mod paths;
|
16
src/helpers/paths.rs
Normal file
16
src/helpers/paths.rs
Normal file
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue