Initial commit
This commit is contained in:
commit
2f3751f968
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
**/*.rs.bk
|
|
@ -0,0 +1,6 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "tfetch"
|
||||
version = "0.1.0"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "tfetch"
|
||||
version = "0.1.0"
|
||||
authors = ["Thomas Forgione <thomas@forgione.fr>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,19 @@
|
|||
pub mod logos;
|
||||
|
||||
pub enum Os {
|
||||
ArchLinux,
|
||||
}
|
||||
|
||||
impl Os {
|
||||
pub fn ascii_logo(self) -> &'static str {
|
||||
match self {
|
||||
Os::ArchLinux => logos::archlinux::ASCII_LOGO,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Os::ArchLinux => "Arch Linux",
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
pub const ASCII_LOGO: &'static str = " \x1B[36;1m-`\x1B[0m \
|
||||
\n \x1B[36;1m.o+`\x1B[0m \
|
||||
\n \x1B[36;1m`ooo/\x1B[0m \
|
||||
\n \x1B[36;1m`+oooo:\x1B[0m \
|
||||
\n \x1B[36;1m`+oooooo:\x1B[0m \
|
||||
\n \x1B[36;1m-+oooooo+:\x1B[0m \
|
||||
\n \x1B[36;1m`/:-:++oooo+:\x1B[0m \
|
||||
\n \x1B[36;1m`/++++/+++++++:\x1B[0m \
|
||||
\n \x1B[36;1m`/++++++++++++++:\x1B[0m \
|
||||
\n \x1B[36;1m`/+++o\x1B[0;36moooooooo\x1B[1moooo/`\x1B[0m \
|
||||
\n \x1B[36;1m./\x1B[0;36mooosssso++osssssso\x1B[1m+`\x1B[0m \
|
||||
\n \x1B[36m.oossssso-````/ossssss+`\x1B[0m \
|
||||
\n \x1B[36m-osssssso. :ssssssso.\x1B[0m \
|
||||
\n \x1B[36m:osssssss/ osssso+++.\x1B[0m \
|
||||
\n \x1B[36m/ossssssss/ +ssssooo/-\x1B[0m \
|
||||
\n \x1B[36m`/ossssso+/:- -:/+osssso+-\x1B[0m \
|
||||
\n \x1B[36m`+sso+:-` `.-/+oso:\x1B[0m \
|
||||
\n\x1B[36m`++:. `-/+/\x1B[0m\
|
||||
\n\x1B[36m.` `/\x1B[0m";
|
||||
|
|
@ -0,0 +1 @@
|
|||
pub mod archlinux;
|
|
@ -0,0 +1,32 @@
|
|||
use std::env::var;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
use tfetch::Os;
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let mut hostname = String::new();
|
||||
let mut hostname_file = File::open("/etc/hostname").unwrap();
|
||||
hostname_file.read_to_string(&mut hostname).unwrap();
|
||||
|
||||
let username = format!("\x1B[36;1m{}\x1B[0m@\x1B[36;1m{}\x1B[0m", var("USER").unwrap(), hostname);
|
||||
let osname = format!("\x1B[36;1mOS:\x1B[0m {}\n", Os::ArchLinux.name());
|
||||
|
||||
let info = [
|
||||
String::from("\n"),
|
||||
username,
|
||||
osname,
|
||||
];
|
||||
|
||||
let mut logo_iterator = Os::ArchLinux.ascii_logo().lines();
|
||||
let mut info_iterator = info.iter();
|
||||
|
||||
loop {
|
||||
match (logo_iterator.next(), info_iterator.next()) {
|
||||
(Some(logo), Some(info)) => print!("{} {}", logo, info),
|
||||
(Some(logo), None) => println!("{}", logo),
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue