Skip to content

Commit f438db2

Browse files
author
Arthur Melton
committed
Neofetch.nys and also uses and a fuck ton of other stuff
1 parent 0bef466 commit f438db2

File tree

8 files changed

+1224
-1001
lines changed

8 files changed

+1224
-1001
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ meval = "0.2.0"
1717
rustc-serialize = "0.3.24"
1818
openssl = { version = "0.10", features = ["vendored"] }
1919
sysinfo = "0.20.0"
20+
humantime = "2.1.0"
2021

examples/Music.nys

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use audio;
2+
13
log("What do you want to play (file location)");
24
dec str play: input();
35
log("What do you want to loop the music (y or n)");

examples/Neofetch.nys

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use os;
2+
3+
log("
4+
5+
```````````````````````
6+
`:///////////////////-`
7+
`://///////////////-`
8+
`:///////////////:. OS: "os.name()"
9+
`://////-........
10+
`://////` Hostname: "os.host_name()"
11+
`://////` ...` `.. `.`
12+
`://////` ....` `.. ...` Version: "os.os_version()"
13+
`://///:` ..... `.. `.--.`
14+
`:////-` ..` .. `.. `.----.` Kernel: "os.kernel_version()"
15+
`://-` ..` ..... .------.`
16+
`::. ..` `.... .------.` Uptime: "timeh(" ", math(os.uptime()*1000))"
17+
`. ..` `... .------.`
18+
.------.` Ram: "math(os.used_memory()/1000)"MB / "math(os.total_memory()/1000)"MB
19+
````````.------.`
20+
`.---------------.` Swap: "math(os.used_swap()/1000)"MB / "math(os.total_swap()/1000)"MB
21+
`.-----------------.`
22+
`.-------------------.`
23+
```````````````````````
24+
25+
")

examples/test.nys

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
use os;
2-
log(os);
1+
use audio;
2+
audio();

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
let mut compile = false;
2828
let mut hard = false;
2929
let mut run = false;
30-
let mut uses:Vec<String> = vec!["false".to_string()];
30+
let uses:Vec<String> = vec!["false".to_string(), "false".to_string()];
3131
for arg in args {
3232
if arg == "--dev" {
3333
dev = true;

src/run.rs

Lines changed: 969 additions & 988 deletions
Large diffs are not rendered by default.

src/run/functions.rs

Lines changed: 217 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern crate chrono;
1111
use chrono::prelude::DateTime;
1212
use chrono::Utc;
1313
use rustc_serialize::json::Json;
14-
use sysinfo::SystemExt;
14+
use sysinfo::{SystemExt, ProcessorExt};
1515

1616
extern crate meval;
1717

@@ -650,6 +650,146 @@ pub fn getstring(
650650
}
651651
}
652652
skips = leng;
653+
} else if vec[y] == "os.uptime" && uses[0] == "true".to_string() {
654+
use sysinfo::System;
655+
let mut sys = System::new_all();
656+
sys.refresh_all();
657+
imput_s.push_str(sys.uptime().to_string().as_str());
658+
let mut leng = 0;
659+
let mut n2 = 0;
660+
let mut skip1 = false;
661+
for f in y + 1..vec.len() {
662+
if !skip1 {
663+
if vec[y + 1] != "(" {
664+
println!("You have to put a parentheses after a log");
665+
std::process::exit(1);
666+
}
667+
if vec[f] == "(" {
668+
n2 += 1;
669+
} else if vec[f] == ")" {
670+
n2 -= 1;
671+
}
672+
if n2 == 0 {
673+
skip1 = true;
674+
for _z in y + 1..f + 1 {
675+
leng += 1;
676+
}
677+
}
678+
}
679+
}
680+
skips = leng;
681+
} else if vec[y] == "os.name" && uses[0] == "true".to_string() {
682+
use sysinfo::System;
683+
let mut sys = System::new_all();
684+
sys.refresh_all();
685+
imput_s.push_str(sys.name().unwrap().to_string().as_str());
686+
let mut leng = 0;
687+
let mut n2 = 0;
688+
let mut skip1 = false;
689+
for f in y + 1..vec.len() {
690+
if !skip1 {
691+
if vec[y + 1] != "(" {
692+
println!("You have to put a parentheses after a log");
693+
std::process::exit(1);
694+
}
695+
if vec[f] == "(" {
696+
n2 += 1;
697+
} else if vec[f] == ")" {
698+
n2 -= 1;
699+
}
700+
if n2 == 0 {
701+
skip1 = true;
702+
for _z in y + 1..f + 1 {
703+
leng += 1;
704+
}
705+
}
706+
}
707+
}
708+
skips = leng;
709+
} else if vec[y] == "os.kernel_version" && uses[0] == "true".to_string() {
710+
use sysinfo::System;
711+
let mut sys = System::new_all();
712+
sys.refresh_all();
713+
imput_s.push_str(sys.kernel_version().unwrap().to_string().as_str());
714+
let mut leng = 0;
715+
let mut n2 = 0;
716+
let mut skip1 = false;
717+
for f in y + 1..vec.len() {
718+
if !skip1 {
719+
if vec[y + 1] != "(" {
720+
println!("You have to put a parentheses after a log");
721+
std::process::exit(1);
722+
}
723+
if vec[f] == "(" {
724+
n2 += 1;
725+
} else if vec[f] == ")" {
726+
n2 -= 1;
727+
}
728+
if n2 == 0 {
729+
skip1 = true;
730+
for _z in y + 1..f + 1 {
731+
leng += 1;
732+
}
733+
}
734+
}
735+
}
736+
skips = leng;
737+
} else if vec[y] == "os.os_version" && uses[0] == "true".to_string() {
738+
use sysinfo::System;
739+
let mut sys = System::new_all();
740+
sys.refresh_all();
741+
imput_s.push_str(sys.os_version().unwrap().to_string().as_str());
742+
let mut leng = 0;
743+
let mut n2 = 0;
744+
let mut skip1 = false;
745+
for f in y + 1..vec.len() {
746+
if !skip1 {
747+
if vec[y + 1] != "(" {
748+
println!("You have to put a parentheses after a log");
749+
std::process::exit(1);
750+
}
751+
if vec[f] == "(" {
752+
n2 += 1;
753+
} else if vec[f] == ")" {
754+
n2 -= 1;
755+
}
756+
if n2 == 0 {
757+
skip1 = true;
758+
for _z in y + 1..f + 1 {
759+
leng += 1;
760+
}
761+
}
762+
}
763+
}
764+
skips = leng;
765+
} else if vec[y] == "os.host_name" && uses[0] == "true".to_string() {
766+
use sysinfo::System;
767+
let mut sys = System::new_all();
768+
sys.refresh_all();
769+
imput_s.push_str(sys.host_name().unwrap().to_string().as_str());
770+
let mut leng = 0;
771+
let mut n2 = 0;
772+
let mut skip1 = false;
773+
for f in y + 1..vec.len() {
774+
if !skip1 {
775+
if vec[y + 1] != "(" {
776+
println!("You have to put a parentheses after a log");
777+
std::process::exit(1);
778+
}
779+
if vec[f] == "(" {
780+
n2 += 1;
781+
} else if vec[f] == ")" {
782+
n2 -= 1;
783+
}
784+
if n2 == 0 {
785+
skip1 = true;
786+
for _z in y + 1..f + 1 {
787+
leng += 1;
788+
}
789+
}
790+
}
791+
}
792+
skips = leng;
653793
} else if vec[y] == "os.used_memory" && uses[0] == "true".to_string() {
654794
use sysinfo::System;
655795
let mut sys = System::new_all();
@@ -762,6 +902,62 @@ pub fn getstring(
762902
}
763903
}
764904
skips = leng;
905+
} else if vec[y] == "os.cpu_usage" && uses[0] == "true".to_string() {
906+
use sysinfo::System;
907+
let mut sys = System::new_all();
908+
sys.refresh_all();
909+
imput_s.push_str(sys.global_processor_info().cpu_usage().to_string().as_str());
910+
let mut leng = 0;
911+
let mut n2 = 0;
912+
let mut skip1 = false;
913+
for f in y + 1..vec.len() {
914+
if !skip1 {
915+
if vec[y + 1] != "(" {
916+
println!("You have to put a parentheses after a log");
917+
std::process::exit(1);
918+
}
919+
if vec[f] == "(" {
920+
n2 += 1;
921+
} else if vec[f] == ")" {
922+
n2 -= 1;
923+
}
924+
if n2 == 0 {
925+
skip1 = true;
926+
for _z in y + 1..f + 1 {
927+
leng += 1;
928+
}
929+
}
930+
}
931+
}
932+
skips = leng;
933+
} else if vec[y] == "os.cpu_name" && uses[0] == "true".to_string() {
934+
use sysinfo::System;
935+
let mut sys = System::new_all();
936+
sys.refresh_all();
937+
imput_s.push_str(sys.global_processor_info().name().to_string().as_str());
938+
let mut leng = 0;
939+
let mut n2 = 0;
940+
let mut skip1 = false;
941+
for f in y + 1..vec.len() {
942+
if !skip1 {
943+
if vec[y + 1] != "(" {
944+
println!("You have to put a parentheses after a log");
945+
std::process::exit(1);
946+
}
947+
if vec[f] == "(" {
948+
n2 += 1;
949+
} else if vec[f] == ")" {
950+
n2 -= 1;
951+
}
952+
if n2 == 0 {
953+
skip1 = true;
954+
for _z in y + 1..f + 1 {
955+
leng += 1;
956+
}
957+
}
958+
}
959+
}
960+
skips = leng;
765961
} else if vec[y] == "os.load_average.five" && uses[0] == "true".to_string() {
766962
use sysinfo::System;
767963
let mut sys = System::new_all();
@@ -1714,14 +1910,20 @@ pub fn time_readable(
17141910
0,
17151911
);
17161912
if !getstirng.is_empty() {
1717-
let time: f64 = getstirng.first().unwrap().parse().unwrap();
1718-
println!("{}", time);
1719-
let d = UNIX_EPOCH + Duration::from_millis(time as u64);
1720-
// Create DateTime from SystemTime
1721-
let datetime = DateTime::<Utc>::from(d);
1722-
// Formats the combined date and time with the specified format string.
1723-
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S.%f").to_string();
1724-
timestamp_str
1913+
let time: f64 = getstirng.get(0).unwrap().parse().unwrap();
1914+
if getstirng.first().unwrap() == "true" {
1915+
let d:SystemTime = UNIX_EPOCH + Duration::from_millis(time as u64);
1916+
// Create DateTime from SystemTime
1917+
let datetime = DateTime::<Utc>::from(d);
1918+
// Formats the combined date and time with the specified format string.
1919+
let timestamp_str = datetime.format(getstirng.get(1).unwrap()).to_string();
1920+
timestamp_str
1921+
}
1922+
else {
1923+
use humantime::format_duration;
1924+
let d = Duration::from_millis(time as u64);
1925+
format_duration(d).to_string()
1926+
}
17251927
} else {
17261928
let time = time();
17271929
let d = UNIX_EPOCH + Duration::from_millis(time as u64);
@@ -1740,7 +1942,12 @@ pub fn get_line(x: usize, contents: Vec<String>) -> i32 {
17401942
line += 1;
17411943
}
17421944
}
1743-
(line - run::code_to_add().matches('\n').count() + 1) as i32
1945+
if line >= run::code_to_add().matches('\n').count() {
1946+
return (line - run::code_to_add().matches('\n').count() + 1) as i32
1947+
}
1948+
else {
1949+
return (line + 1) as i32
1950+
}
17441951
}
17451952

17461953
pub fn request(

0 commit comments

Comments
 (0)