Skip to content

Feat/cs/cargo fixes #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
538 changes: 398 additions & 140 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ repository = "https://github.com/ReagentX/Logria"
version = "0.0.0"

[dependencies]
clap = {version = "4.0.10", features = ["cargo"]}
crossterm = "0.25.0"
dirs = "4.0.0"
format_num = "0.1.0"
is_executable = "1.0.1"
regex = "1.6.0"
serde = {version = "1.0.139", features = ["derive"]}
serde_json = "1.0.82"
time = {version = "0.3.11", features = ["formatting", "parsing"]}
tokio = {version = "1.25.0", features = [
clap = { version = "=4.5.23", features = ["cargo"] }
crossterm = "=0.28.1"
dirs = "=5.0.1"
format_num = "=0.1.0"
is_executable = "=1.0.4"
regex = "=1.11.1"
serde = { version = "=1.0.216", features = ["derive"] }
serde_json = "=1.0.134"
time = { version = "=0.3.37", features = ["formatting", "parsing"] }
tokio = { version = "=1.42.0", features = [
"process",
"io-util",
"rt-multi-thread",
"macros",
]}
] }
4 changes: 2 additions & 2 deletions src/communication/handlers/command.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io::{stdout, Write};
use std::io::{stdout, Result, Write};

use crossterm::{event::KeyCode, Result};
use crossterm::event::KeyCode;

use super::handler::Handler;
use crate::{
Expand Down
3 changes: 2 additions & 1 deletion src/communication/handlers/handler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crossterm::Result;
use std::io::Result;

use crossterm::event::KeyCode;

use crate::communication::reader::MainWindow;
Expand Down
3 changes: 1 addition & 2 deletions src/communication/handlers/multiple_choice.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;
use std::{collections::HashMap, io::Result};

use crossterm::event::KeyCode;
use crossterm::Result;

use crate::{
communication::{
Expand Down
4 changes: 2 additions & 2 deletions src/communication/handlers/normal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io::stdout;
use std::io::{stdout, Result};

use crossterm::{cursor, event::KeyCode, queue, Result};
use crossterm::{cursor, event::KeyCode, queue};

use super::handler::Handler;
use crate::{
Expand Down
6 changes: 3 additions & 3 deletions src/communication/handlers/parser.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::Path;
use std::{io::Result, path::Path};

use crossterm::{event::KeyCode, Result};
use crossterm::event::KeyCode;
use regex::Regex;

use crate::{
Expand Down Expand Up @@ -279,7 +279,7 @@ impl Handler for ParserHandler {
}
}

fn receive_input(&mut self, window: &mut MainWindow, key: KeyCode) -> crossterm::Result<()> {
fn receive_input(&mut self, window: &mut MainWindow, key: KeyCode) -> Result<()> {
// Enable command mode for parsers
if key == KeyCode::Char(':') {
window.set_command_mode(Some(Parser::del))?;
Expand Down
2 changes: 1 addition & 1 deletion src/communication/handlers/processor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crossterm::Result;
use std::io::Result;

use crate::communication::reader::MainWindow;

Expand Down
4 changes: 3 additions & 1 deletion src/communication/handlers/regex.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crossterm::{event::KeyCode, Result};
use std::io::Result;

use crossterm::event::KeyCode;
use regex::bytes::Regex;

use super::{handler::Handler, processor::ProcessorMethods};
Expand Down
4 changes: 2 additions & 2 deletions src/communication/handlers/startup.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::{collections::HashMap, io::Result};

use crossterm::{event::KeyCode, Result};
use crossterm::event::KeyCode;

use super::{handler::Handler, user_input::UserInputHandler};
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions src/communication/handlers/user_input.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{
cmp::{max, min},
io::{stdout, Write},
io::{stdout, Write, Result},
};

use crossterm::{cursor, event::KeyCode, queue, style, terminal::size, Result};
use crossterm::{cursor, event::KeyCode, queue, style, terminal::size};

use crate::{
communication::{handlers::handler::Handler, reader::MainWindow},
Expand Down
10 changes: 2 additions & 8 deletions src/communication/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ use tokio::{
pub struct InputStream {
pub stdout: Receiver<String>,
pub stderr: Receiver<String>,
pub process_name: String,
pub process: Result<std::thread::JoinHandle<()>, std::io::Error>,
pub should_die: Arc<Mutex<bool>>,
pub _type: String,
}
Expand Down Expand Up @@ -74,7 +72,7 @@ impl Input for FileInput {
};

// Start process
let process = thread::Builder::new()
let _ = thread::Builder::new()
.name(format!("FileInput: {}", name))
.spawn(move || {
// Create a buffer and read from it
Expand All @@ -94,8 +92,6 @@ impl Input for FileInput {
Ok(InputStream {
stdout: out_rx,
stderr: err_rx,
process_name: name,
process,
should_die: Arc::new(Mutex::new(false)),
_type: String::from("FileInput"),
})
Expand Down Expand Up @@ -127,7 +123,7 @@ impl Input for CommandInput {
let mut poll_rate = RollingMean::new(5);

// Start reading from the queues
let process = thread::Builder::new()
let _ = thread::Builder::new()
.name(format!("CommandInput: {}", name))
.spawn(move || {
let runtime = Runtime::new().unwrap();
Expand Down Expand Up @@ -186,8 +182,6 @@ impl Input for CommandInput {
Ok(InputStream {
stdout: out_rx,
stderr: err_rx,
process_name: name,
process,
should_die,
_type: String::from("CommandInput"),
})
Expand Down
9 changes: 2 additions & 7 deletions src/communication/reader.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
cmp::max,
io::{stdout, Write},
io::{stdout, Result, Write},
panic,
time::{Duration, Instant},
};
Expand All @@ -10,7 +10,6 @@ use crossterm::{
event::{poll, read, Event, KeyCode, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers},
execute, queue, style,
terminal::{disable_raw_mode, size, Clear, ClearType},
Result,
};
use regex::bytes::Regex;

Expand All @@ -19,7 +18,6 @@ use crate::{
handlers::{
command::CommandHandler,
handler::Handler,
multiple_choice::MultipleChoiceHandler,
normal::NormalHandler,
parser::{ParserHandler, ParserState},
processor::ProcessorMethods,
Expand Down Expand Up @@ -125,8 +123,6 @@ pub struct MainWindow {
pub config: LogriaConfig,
pub input_type: InputType,
pub previous_input_type: InputType,
// pub output: Stdout,
pub mc_handler: MultipleChoiceHandler,
length_finder: LengthFinder,
}

Expand Down Expand Up @@ -201,7 +197,6 @@ impl MainWindow {
input_type: InputType::Startup,
previous_input_type: InputType::Startup,
length_finder: LengthFinder::new(),
mc_handler: MultipleChoiceHandler::new(),
config: LogriaConfig {
poll_rate: DEFAULT,
smart_poll_rate,
Expand Down Expand Up @@ -485,7 +480,7 @@ impl MainWindow {

// Get some metadata we need to render the message
let message_length = self.length_finder.get_real_length(message);
let message_rows = max(1, ((message_length) + (width - 1)) / width);
let message_rows = max(1, (message_length).div_ceil(width));

// Update the current row, stop writing if there is no more space
current_row = match current_row.checked_sub(max(1, message_rows as u16)) {
Expand Down
16 changes: 8 additions & 8 deletions src/extensions/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

impl Parser {
/// Create an instance of a parser
pub fn new(

Check warning on line 122 in src/extensions/parser.rs

View workflow job for this annotation

GitHub Actions / clippy

associated function `new` is never used

warning: associated function `new` is never used --> src/extensions/parser.rs:122:12 | 120 | impl Parser { | ----------- associated function in this implementation 121 | /// Create an instance of a parser 122 | pub fn new( | ^^^ | = note: `#[warn(dead_code)]` on by default
pattern: String,
pattern_type: PatternType,
example: String,
Expand Down Expand Up @@ -623,7 +623,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -641,7 +641,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -661,7 +661,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -676,7 +676,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -691,7 +691,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -706,7 +706,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -721,7 +721,7 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}

#[test]
Expand All @@ -736,6 +736,6 @@
map,
);
parser.setup();
assert!(parser.aggregator_map.get("1").is_some());
assert!(parser.aggregator_map.contains_key("1"));
}
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![forbid(unsafe_code)]

use crossterm::Result;
use std::io::Result;

mod communication;
mod constants;
Expand Down
5 changes: 3 additions & 2 deletions src/ui/interface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crossterm::{cursor, execute, queue, style, terminal, tty::IsTty, Result};
use std::io::{stdin, stdout, Stdout, Write};
use std::io::{stdin, stdout, Result, Stdout, Write};

use crossterm::{cursor, execute, queue, style, terminal, tty::IsTty};

use crate::communication::reader::MainWindow;

Expand Down
Loading