Skip to content

Commit df6d0df

Browse files
kianmengpythops
andauthored
Fix typos (#36)
Co-authored-by: Badr <[email protected]>
1 parent 008b36f commit df6d0df

File tree

11 files changed

+530
-550
lines changed

11 files changed

+530
-550
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ repository = "https://github.com/pythops/impala"
1212
[dependencies]
1313
async-channel = "2"
1414
crossterm = { version = "0.28", default-features = false, features = [
15-
"event-stream",
15+
"event-stream",
1616
] }
1717
ratatui = "0.29"
1818
tui-input = "0.11"
1919
tokio = { version = "1", features = ["full"] }
2020
futures = "0.3"
21-
dirs = "5"
21+
dirs = "6"
2222
serde = { version = "1", features = ["derive"] }
2323
toml = { version = "0.8" }
2424
clap = { version = "4", features = ["derive", "cargo"] }

src/access_point.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct AccessPoint {
4343
impl AccessPoint {
4444
pub async fn new(session: Arc<Session>) -> AppResult<Self> {
4545
let iwd_access_point = session.access_point().unwrap();
46-
let iwd_access_point_diagnotic = session.access_point_diagnostic();
46+
let iwd_access_point_diagnostic = session.access_point_diagnostic();
4747

4848
let has_started = iwd_access_point.has_started().await?;
4949
let name = iwd_access_point.name().await?;
@@ -58,7 +58,7 @@ impl AccessPoint {
5858
let focused_section = APFocusedSection::SSID;
5959

6060
let connected_devices = {
61-
if let Some(d) = iwd_access_point_diagnotic {
61+
if let Some(d) = iwd_access_point_diagnostic {
6262
match d.get().await {
6363
Ok(diagnostic) => diagnostic
6464
.iter()
@@ -208,7 +208,7 @@ impl AccessPoint {
208208

209209
pub async fn refresh(&mut self) -> AppResult<()> {
210210
let iwd_access_point = self.session.access_point().unwrap();
211-
let iwd_access_point_diagnotic = self.session.access_point_diagnostic();
211+
let iwd_access_point_diagnostic = self.session.access_point_diagnostic();
212212

213213
self.has_started = iwd_access_point.has_started().await?;
214214
self.name = iwd_access_point.name().await?;
@@ -217,7 +217,7 @@ impl AccessPoint {
217217
self.supported_ciphers = iwd_access_point.pairwise_ciphers().await?;
218218
self.used_cipher = iwd_access_point.group_cipher().await?;
219219

220-
if let Some(d) = iwd_access_point_diagnotic {
220+
if let Some(d) = iwd_access_point_diagnostic {
221221
if let Ok(diagnostic) = d.get().await {
222222
self.connected_devices = diagnostic
223223
.iter()

src/adapter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl Adapter {
724724
let row = vec![
725725
Line::from("󰸞").centered(),
726726
Line::from(net.name.clone()).centered(),
727-
Line::from(net.netowrk_type.clone()).centered(),
727+
Line::from(net.network_type.clone()).centered(),
728728
Line::from(net.is_hidden.to_string()).centered(),
729729
Line::from(net.is_autoconnect.to_string()).centered(),
730730
Line::from(signal).centered(),
@@ -735,7 +735,7 @@ impl Adapter {
735735
let row = vec![
736736
Line::from(""),
737737
Line::from(net.name.clone()).centered(),
738-
Line::from(net.netowrk_type.clone()).centered(),
738+
Line::from(net.network_type.clone()).centered(),
739739
Line::from(net.is_hidden.to_string()).centered(),
740740
Line::from(net.is_autoconnect.to_string()).centered(),
741741
Line::from(signal).centered(),
@@ -747,7 +747,7 @@ impl Adapter {
747747
let row = vec![
748748
Line::from("").centered(),
749749
Line::from(net.name.clone()).centered(),
750-
Line::from(net.netowrk_type.clone()).centered(),
750+
Line::from(net.network_type.clone()).centered(),
751751
Line::from(net.is_hidden.to_string()).centered(),
752752
Line::from(net.is_autoconnect.to_string()).centered(),
753753
Line::from(signal).centered(),
@@ -881,7 +881,7 @@ impl Adapter {
881881
.map(|(net, signal)| {
882882
Row::new(vec![
883883
Line::from(net.name.clone()).centered(),
884-
Line::from(net.netowrk_type.clone()).centered(),
884+
Line::from(net.network_type.clone()).centered(),
885885
Line::from({
886886
let signal = {
887887
if *signal / 100 >= -50 {
@@ -891,10 +891,10 @@ impl Adapter {
891891
}
892892
};
893893
match signal {
894-
n if n >= 75 => format!("{:3}% 󰤨", signal),
895-
n if (50..75).contains(&n) => format!("{:3}% 󰤥", signal),
896-
n if (25..50).contains(&n) => format!("{:3}% 󰤢", signal),
897-
_ => format!("{:3}% 󰤟", signal),
894+
n if n >= 75 => format!("{signal:3}% 󰤨"),
895+
n if (50..75).contains(&n) => format!("{signal:3}% 󰤥"),
896+
n if (25..50).contains(&n) => format!("{signal:3}% 󰤢"),
897+
_ => format!("{signal:3}% 󰤟"),
898898
}
899899
})
900900
.centered(),

src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl App {
9696
match iwdrs::session::Session::new().await {
9797
Ok(session) => Arc::new(session),
9898
Err(e) => {
99-
eprintln!("Can not access the iwd service {}", e);
99+
eprintln!("Can not access the iwd service {e}");
100100
exit(1);
101101
}
102102
}
@@ -105,7 +105,7 @@ impl App {
105105
let adapter = match Adapter::new(session.clone(), sender).await {
106106
Ok(v) => v,
107107
Err(e) => {
108-
eprintln!("{}", e);
108+
eprintln!("{e}");
109109
eprintln!("Make sure iwd daemon is up and running");
110110
process::exit(1);
111111
}
@@ -174,7 +174,7 @@ impl App {
174174
let adapter = match Adapter::new(session.clone(), sender).await {
175175
Ok(v) => v,
176176
Err(e) => {
177-
eprintln!("{}", e);
177+
eprintln!("{e}");
178178
eprintln!("Make sure iwd daemon is up and running");
179179
process::exit(1);
180180
}
@@ -277,7 +277,7 @@ impl App {
277277
),
278278
_ => (Text::from(" Access Point"), Text::from(" Station")),
279279
},
280-
_ => panic!("unknwon mode"),
280+
_ => panic!("unknown mode"),
281281
};
282282

283283
let message = Paragraph::new("Select the desired mode:")

src/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Device {
9595
Mode::Station => {
9696
match self.mode {
9797
Mode::Station => {
98-
// refresh exisiting station
98+
// refresh existing station
9999
if let Some(station) = &mut self.station {
100100
station.refresh().await?;
101101
}

src/event.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ impl EventHandler {
7070
self.receiver
7171
.recv()
7272
.await
73-
.ok_or(Box::new(std::io::Error::new(
74-
std::io::ErrorKind::Other,
75-
"This is an IO error",
76-
)))
73+
.ok_or(Box::new(std::io::Error::other("This is an IO error")))
7774
}
7875
}

src/handler.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -465,16 +465,15 @@ pub async fn handle_key_events(
465465
== selected_net.name
466466
});
467467

468-
if net_index.is_some() {
468+
if let Some(index) = net_index {
469469
let (net, _) = app
470470
.adapter
471471
.device
472472
.station
473473
.as_ref()
474474
.unwrap()
475-
.known_networks
476-
[net_index.unwrap()]
477-
.clone();
475+
.known_networks[index]
476+
.clone();
478477
app.adapter
479478
.device
480479
.station
@@ -525,16 +524,15 @@ pub async fn handle_key_events(
525524
n.name == selected_net.name
526525
});
527526

528-
if net_index.is_some() {
527+
if let Some(index) = net_index {
529528
let (net, _) = app
530529
.adapter
531530
.device
532531
.station
533532
.as_ref()
534533
.unwrap()
535-
.known_networks
536-
[net_index.unwrap()]
537-
.clone();
534+
.known_networks[index]
535+
.clone();
538536
tokio::spawn(async move {
539537
net.connect(sender.clone())
540538
.await
@@ -675,13 +673,7 @@ pub async fn handle_key_events(
675673
.known_networks_state
676674
.selected()
677675
{
678-
Some(i) => {
679-
if i > 1 {
680-
i - 1
681-
} else {
682-
0
683-
}
684-
}
676+
Some(i) => i.saturating_sub(1),
685677
None => 0,
686678
};
687679

@@ -713,13 +705,7 @@ pub async fn handle_key_events(
713705
.new_networks_state
714706
.selected()
715707
{
716-
Some(i) => {
717-
if i > 1 {
718-
i - 1
719-
} else {
720-
0
721-
}
722-
}
708+
Some(i) => i.saturating_sub(1),
723709
None => 0,
724710
};
725711

src/help.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,7 @@ impl Help {
119119
}
120120
pub fn scroll_up(&mut self) {
121121
let i = match self.state.selected() {
122-
Some(i) => {
123-
if i > 1 {
124-
i - 1
125-
} else {
126-
0
127-
}
128-
}
122+
Some(i) => i.saturating_sub(1),
129123
None => 1,
130124
};
131125
*self.state.offset_mut() = i;

src/known_network.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
pub struct KnownNetwork {
1414
pub n: iwdKnownNetwork,
1515
pub name: String,
16-
pub netowrk_type: String,
16+
pub network_type: String,
1717
pub is_autoconnect: bool,
1818
pub is_hidden: bool,
1919
pub last_connected: Option<DateTime<FixedOffset>>,
@@ -22,7 +22,7 @@ pub struct KnownNetwork {
2222
impl KnownNetwork {
2323
pub async fn new(n: iwdKnownNetwork) -> AppResult<Self> {
2424
let name = n.name().await?;
25-
let netowrk_type = n.network_type().await?;
25+
let network_type = n.network_type().await?;
2626
let is_autoconnect = n.get_autoconnect().await?;
2727
let is_hidden = n.hidden().await?;
2828
let last_connected = match n.last_connected_time().await {
@@ -33,7 +33,7 @@ impl KnownNetwork {
3333
Ok(Self {
3434
n,
3535
name,
36-
netowrk_type,
36+
network_type,
3737
is_autoconnect,
3838
is_hidden,
3939
last_connected,

0 commit comments

Comments
 (0)