Skip to content
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

Fix linter errors #8

Merged
merged 1 commit into from
May 18, 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
4 changes: 2 additions & 2 deletions .github/workflows/build-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
nix build
- name: Test
run: |
nix develop --ignore-environment --command "cargo" "test"
nix build .#test
- name: Lint
run: |
nix develop --ignore-environment --command "cargo" "clippy"
nix build .#clippy
14 changes: 13 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@
};

in rec {
defaultPackage = naersk'.buildPackage { src = ./.; };
packages = {
default = naersk'.buildPackage {
src = ./.;
};
test = naersk'.buildPackage {
src = ./.;
mode = "test";
};
clippy = naersk'.buildPackage {
src = ./.;
mode = "clippy";
};
};

devShell = pkgs.mkShell { nativeBuildInputs = [ toolchain pkgs.rust-analyzer ]; };
});
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use crate::app::App;
use crate::taskui::{App, Config};
use anyhow::Result;
use app::{
use ratatui::{backend::CrosstermBackend, Terminal};
use taskui::{
event::{Event, EventHandler},
terminal::UserInterface,
update,
};
use ratatui::{backend::CrosstermBackend, Terminal};

mod app;
mod taskfile;
mod taskui;

fn main() -> Result<()> {
let taskfile = taskfile::config::load()?;

let cfg = app::Config::load();
let cfg = Config::load();
let mut app = App::new(cfg, taskfile);

let backend = CrosstermBackend::new(std::io::stderr());
Expand Down
8 changes: 4 additions & 4 deletions src/taskfile/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub fn load() -> Result<Vec<Task>> {
current_path.to_str().unwrap(),
)?;

tasks.extend(included_tasks.into_iter());
tasks.extend(included_tasks);

Ok(tasks)
}

fn find_supported_file() -> Result<&'static str> {
// https://taskfile.dev/usage/#supported-file-names
let file_names = vec![
let file_names = [
"Taskfile.yml",
"taskfile.yml",
"Taskfile.yaml",
Expand All @@ -53,7 +53,7 @@ fn find_supported_file() -> Result<&'static str> {
let found = file_names
.iter()
.find(|&file_name| metadata(file_name).is_ok())
.map(|&file_name| file_name);
.copied();

match found {
Some(file_name) => Ok(file_name),
Expand Down Expand Up @@ -175,7 +175,7 @@ fn extract_include_path(include_yml: &Value) -> Result<String> {
Value::String(path) if path.ends_with(".yml") || path.ends_with(".yaml") => {
path.to_string()
}
Value::String(path) if path.ends_with("/") => format!("{}Taskfile.yml", path),
Value::String(path) if path.ends_with('/') => format!("{}Taskfile.yml", path),
Value::String(path) => format!("{}/Taskfile.yml", path),
Value::Mapping(v) => {
if let Some(taskfile) = v.get(&Value::String("taskfile".to_string())) {
Expand Down
8 changes: 4 additions & 4 deletions src/app/app.rs → src/taskui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl StatefulList {
}

pub fn next(&mut self) {
if self.items.len() == 0 {
if self.items.is_empty() {
self.reset_selected();
return;
}
Expand All @@ -89,7 +89,7 @@ impl StatefulList {
}

pub fn previous(&mut self) {
if self.items.len() == 0 {
if self.items.is_empty() {
self.reset_selected();
return;
}
Expand Down Expand Up @@ -122,11 +122,11 @@ impl StatefulList {
}

pub fn filter(&mut self, search: &String) {
self.items = self.orig_items.clone();
self.items.clone_from(&self.orig_items);
self.items.retain(|i| i.item.name.contains(search));
self.state = ListState::default();

if self.items.len() > 0 {
if !self.items.is_empty() {
self.state.select(Some(0));
} else {
self.state.select(None);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.