Skip to content

Commit 737e2d5

Browse files
authored
Merge pull request #52 from CardboardTurkey/feat/words
Improve installation process
2 parents 9f8bbd7 + 7043a1e commit 737e2d5

File tree

20 files changed

+1249
-188
lines changed

20 files changed

+1249
-188
lines changed

Cargo.lock

Lines changed: 1088 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
@@ -16,3 +16,4 @@ lazy_static = "1.5.0"
1616
anyhow = "1.0.95"
1717
chrono = { version = "0.4", features = ["serde"] }
1818
comfy-table = "7.1.4"
19+
reqwest = { version = "0.12.12", features = ["blocking"] }

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ word and asks you to type it as fast as possible. The game tracks your typing sp
2727
different game modes, such as uppercase and punctuation, to help you improve your typing skills in different areas.
2828

2929
## Installation
30-
To install Typy on Linux, you can use the following command:
30+
To install Typy, you can use the [Cargo] package manager:
31+
32+
[Cargo]: https://doc.rust-lang.org/cargo/
3133

3234
```bash
33-
curl -sSL https://raw.githubusercontent.com/Pazl27/typy-cli/master/scripts/install.sh | bash
35+
cargo install --git "https://github.com/Pazl27/typy-cli.git" --tag "v0.8.0"
3436
```
3537

36-
This command downloads and runs the installation script from the Typy GitHub repository. The script will handle the installation process for you, ensuring that Typy is set up correctly on your system.
37-
3838
If you prefer to get the newest version and compile it yourself, follow these steps:
3939

4040
1. Clone the Typy repository:
@@ -156,5 +156,5 @@ If you want to provide a new language to the Typy repository, feel free to creat
156156
157157
## Uninstall
158158
```bash
159-
curl -sSL https://raw.githubusercontent.com/Pazl27/typy-cli/master/scripts/uninstall.sh | bash
159+
cargo uninstall typy-cli
160160
```

scripts/install.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

scripts/uninstall.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/config/config_tables/cursor_style.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ use crate::config::toml_parser::get_config;
44
use crate::config::toml_parser::CursorTable;
55

66
pub struct CursorKind {
7-
pub style: SetCursorStyle
7+
pub style: SetCursorStyle,
88
}
99

1010
impl CursorKind {
1111
pub fn new() -> Self {
12-
13-
let cursor_table: CursorTable = get_config().lock().unwrap().get_cursor().unwrap_or(CursorTable {
14-
style: Some("DefaultUserShape".to_owned())
15-
});
12+
let cursor_table: CursorTable =
13+
get_config()
14+
.lock()
15+
.unwrap()
16+
.get_cursor()
17+
.unwrap_or(CursorTable {
18+
style: Some("DefaultUserShape".to_owned()),
19+
});
1620

1721
let cursor_kind = match cursor_table.style.as_deref() {
1822
Some("DefaultUserShape") => SetCursorStyle::DefaultUserShape,
@@ -25,17 +29,14 @@ impl CursorKind {
2529
_ => SetCursorStyle::DefaultUserShape,
2630
};
2731

28-
CursorKind {
29-
style: cursor_kind,
30-
}
32+
CursorKind { style: cursor_kind }
3133
}
3234
}
3335

3436
impl Default for CursorKind {
3537
fn default() -> Self {
3638
CursorKind {
37-
style: SetCursorStyle::DefaultUserShape
39+
style: SetCursorStyle::DefaultUserShape,
3840
}
3941
}
4042
}
41-

src/config/config_tables/graph_colors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub struct Graph {
1010

1111
impl Graph {
1212
pub fn new() -> Self {
13-
1413
let theme_colors: Graph = match get_config().lock().unwrap().get_graph() {
1514
Some(colors) => {
1615
let data = colors

src/config/config_tables/mode_settings.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ impl ModeSettings {
1616
let default_modes = settings
1717
.default_mode
1818
.map(|m| {
19-
let modes: Vec<ModeType> = m.split(',')
19+
let modes: Vec<ModeType> = m
20+
.split(',')
2021
.filter_map(|mode| ModeType::from_str(mode.trim()).ok())
2122
.collect();
2223
if modes.contains(&ModeType::Normal) {
@@ -37,7 +38,11 @@ impl ModeSettings {
3738
.map(|c| c.clamp(0.0, 1.0))
3839
.unwrap_or(0.2);
3940

40-
ModeSettings { default_modes, uppercase_chance, punctuation_chance }
41+
ModeSettings {
42+
default_modes,
43+
uppercase_chance,
44+
punctuation_chance,
45+
}
4146
}
4247
None => ModeSettings::default(),
4348
};

src/config/config_tables/theme.rs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub struct ThemeColors {
1212

1313
impl ThemeColors {
1414
pub fn new() -> Self {
15-
1615
let theme_colors: ThemeColors = match get_config().lock().unwrap().get_theme() {
1716
Some(colors) => {
1817
let fg = colors
@@ -67,20 +66,49 @@ fn hex_to_rgb(hex: &str) -> Option<Color> {
6766
}
6867
}
6968

70-
7169
#[cfg(test)]
7270
mod theme_tests {
7371
use super::*;
7472

7573
#[test]
7674
fn test_hex_to_rgb() {
77-
assert_eq!(hex_to_rgb("#ffffff"), Some(Color::Rgb { r: 255, g: 255, b: 255 }));
75+
assert_eq!(
76+
hex_to_rgb("#ffffff"),
77+
Some(Color::Rgb {
78+
r: 255,
79+
g: 255,
80+
b: 255
81+
})
82+
);
7883
assert_eq!(hex_to_rgb("#000000"), Some(Color::Rgb { r: 0, g: 0, b: 0 }));
79-
assert_eq!(hex_to_rgb("#ff0000"), Some(Color::Rgb { r: 255, g: 0, b: 0 }));
80-
assert_eq!(hex_to_rgb("#00ff00"), Some(Color::Rgb { r: 0, g: 255, b: 0 }));
81-
assert_eq!(hex_to_rgb("#0000ff"), Some(Color::Rgb { r: 0, g: 0, b: 255 }));
82-
assert_eq!(hex_to_rgb("#123456"), Some(Color::Rgb { r: 18, g: 52, b: 86 }));
83-
assert_eq!(hex_to_rgb("#abcdef"), Some(Color::Rgb { r: 171, g: 205, b: 239 }));
84+
assert_eq!(
85+
hex_to_rgb("#ff0000"),
86+
Some(Color::Rgb { r: 255, g: 0, b: 0 })
87+
);
88+
assert_eq!(
89+
hex_to_rgb("#00ff00"),
90+
Some(Color::Rgb { r: 0, g: 255, b: 0 })
91+
);
92+
assert_eq!(
93+
hex_to_rgb("#0000ff"),
94+
Some(Color::Rgb { r: 0, g: 0, b: 255 })
95+
);
96+
assert_eq!(
97+
hex_to_rgb("#123456"),
98+
Some(Color::Rgb {
99+
r: 18,
100+
g: 52,
101+
b: 86
102+
})
103+
);
104+
assert_eq!(
105+
hex_to_rgb("#abcdef"),
106+
Some(Color::Rgb {
107+
r: 171,
108+
g: 205,
109+
b: 239
110+
})
111+
);
84112
assert_eq!(hex_to_rgb("#12345"), None);
85113
assert_eq!(hex_to_rgb("#1234567"), None);
86114
assert_eq!(hex_to_rgb("123456"), None);

src/config/toml_parser.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,44 @@
1-
use std::fs;
2-
use toml;
3-
use serde::{Deserialize, Serialize};
41
use dirs::home_dir;
5-
use std::path::PathBuf;
62
use lazy_static::lazy_static;
3+
use serde::{Deserialize, Serialize};
4+
use std::fs;
5+
use std::path::PathBuf;
76
use std::sync::Mutex;
7+
use toml;
88

9-
#[derive(Serialize, Deserialize)]
10-
#[derive(Clone)]
9+
#[derive(Serialize, Deserialize, Clone)]
1110
pub struct ThemeTable {
1211
pub fg: Option<String>,
1312
pub missing: Option<String>,
1413
pub error: Option<String>,
1514
pub accent: Option<String>,
1615
}
1716

18-
#[derive(Serialize, Deserialize)]
19-
#[derive(Clone)]
17+
#[derive(Serialize, Deserialize, Clone)]
2018
pub struct GraphTable {
2119
pub data: Option<String>,
2220
pub title: Option<String>,
2321
pub axis: Option<String>,
2422
}
2523

26-
#[derive(Serialize, Deserialize)]
27-
#[derive(Clone)]
24+
#[derive(Serialize, Deserialize, Clone)]
2825
pub struct CursorTable {
2926
pub style: Option<String>,
3027
}
3128

32-
#[derive(Serialize, Deserialize)]
33-
#[derive(Clone)]
29+
#[derive(Serialize, Deserialize, Clone)]
3430
pub struct ModesTable {
3531
pub default_mode: Option<String>,
3632
pub uppercase_chance: Option<String>,
3733
pub punctuation_chance: Option<String>,
3834
}
3935

40-
#[derive(Serialize, Deserialize)]
41-
#[derive(Clone)]
36+
#[derive(Serialize, Deserialize, Clone)]
4237
pub struct LanguageTable {
43-
pub lang: Option<String>
38+
pub lang: Option<String>,
4439
}
4540

46-
#[derive(Serialize, Deserialize)]
41+
#[derive(Serialize, Deserialize, Default)]
4742
pub struct ConfigToml {
4843
theme: Option<ThemeTable>,
4944
graph: Option<GraphTable>,
@@ -96,18 +91,6 @@ impl ConfigToml {
9691
}
9792
}
9893

99-
impl Default for ConfigToml {
100-
fn default() -> Self {
101-
ConfigToml {
102-
theme: None,
103-
graph: None,
104-
cursor: None,
105-
modes: None,
106-
language: None,
107-
}
108-
}
109-
}
110-
11194
// Declare the static instance of ConfigToml using lazy_static
11295
lazy_static! {
11396
static ref CONFIG: Mutex<ConfigToml> = Mutex::new(ConfigToml::new());
@@ -117,4 +100,3 @@ lazy_static! {
117100
pub fn get_config() -> &'static Mutex<ConfigToml> {
118101
&CONFIG
119102
}
120-

0 commit comments

Comments
 (0)