Skip to content

Commit

Permalink
Merge pull request #57 from triyanox/config-fix
Browse files Browse the repository at this point in the history
Add the ability to set the plugin path with `config --set`
  • Loading branch information
chaqchase authored Dec 14, 2024
2 parents 1f38119 + 510a2df commit 4217cee
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 39 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.4] - 2024-12-14

### Added

- The ability to set plugins path with `config --set`

## [0.3.3] - 2024-12-14

### Added
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["lla", "lla_plugin_interface", "plugins/*"]

[workspace.package]
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["Achaq <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ paru -S lla
pkgin install lla

# Manual - Example is for amd64 GNU, replaces the file names if downloading for a different arch.
wget -c https://github.com/triyanox/lla/releases/download/v0.3.3/lla-linux-amd64 -O lla
wget -c https://github.com/triyanox/lla/releases/download/v0.3.4/lla-linux-amd64 -O lla
sudo chmod +x lla
sudo chown root:root lla
sudo mv lla /usr/local/bin/lla
Expand Down
2 changes: 1 addition & 1 deletion lla/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ walkdir.workspace = true
tempfile.workspace = true
users.workspace = true
parking_lot.workspace = true
lla_plugin_interface = { version = "0.3.3", path = "../lla_plugin_interface" }
lla_plugin_interface = { version = "0.3.4", path = "../lla_plugin_interface" }
once_cell.workspace = true
dashmap.workspace = true
unicode-width.workspace = true
Expand Down
16 changes: 10 additions & 6 deletions lla/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,11 @@ impl Args {
Some(Command::Install(InstallSource::GitHub(
github_url.to_string(),
)))
} else { install_matches.value_of("dir").map(|local_dir| Command::Install(InstallSource::LocalDir(
local_dir.to_string(),
))) }
} else {
install_matches.value_of("dir").map(|local_dir| {
Command::Install(InstallSource::LocalDir(local_dir.to_string()))
})
}
} else if matches.subcommand_matches("list-plugins").is_some() {
Some(Command::ListPlugins)
} else if matches.subcommand_matches("use").is_some() {
Expand All @@ -395,9 +397,11 @@ impl Args {
.map(|v| v.map(String::from).collect())
.unwrap_or_default();
Some(Command::PluginAction(plugin_name, action, args))
} else { matches.subcommand_matches("update").map(|update_matches| Command::Update(
update_matches.value_of("name").map(String::from),
)) };
} else {
matches.subcommand_matches("update").map(|update_matches| {
Command::Update(update_matches.value_of("name").map(String::from))
})
};

Args {
directory: matches.value_of("directory").unwrap_or(".").to_string(),
Expand Down
6 changes: 2 additions & 4 deletions lla/src/commands/plugin_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use std::collections::HashSet;

pub fn list_plugins(plugin_manager: &mut PluginManager) -> Result<()> {
if atty::is(atty::Stream::Stdout) {
let plugins: Vec<(String, String, String)> = plugin_manager
.list_plugins()
.into_iter()
.collect();
let plugins: Vec<(String, String, String)> =
plugin_manager.list_plugins().into_iter().collect();

let plugin_names: Vec<String> = plugins
.iter()
Expand Down
10 changes: 5 additions & 5 deletions lla/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ impl Default for SortConfig {
}
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct FilterConfig {
#[serde(default)]
pub case_sensitive: bool,
}


#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Config {
pub default_sort: String,
Expand Down Expand Up @@ -381,12 +379,14 @@ max_entries = {}"#,
}

for plugin in &self.enabled_plugins {
let possible_names = [format!("lib{}.dylib", plugin),
let possible_names = [
format!("lib{}.dylib", plugin),
format!("lib{}.so", plugin),
format!("{}.dll", plugin),
format!("{}.dylib", plugin),
format!("{}.so", plugin),
plugin.clone()];
plugin.clone(),
];

let exists = possible_names
.iter()
Expand Down
11 changes: 3 additions & 8 deletions lla/src/filter/case_insensitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ impl CaseInsensitiveFilter {

impl FileFilter for CaseInsensitiveFilter {
fn filter_files(&self, files: &[PathBuf]) -> Result<Vec<PathBuf>> {
let lowercase_files: Vec<PathBuf> = files
.iter()
.map(Self::to_lowercase_path)
.collect();
let lowercase_files: Vec<PathBuf> = files.iter().map(Self::to_lowercase_path).collect();

let filtered = self.inner.filter_files(&lowercase_files)?;
let filtered_lowercase: Vec<PathBuf> = filtered
.iter()
.map(Self::to_lowercase_path)
.collect();
let filtered_lowercase: Vec<PathBuf> =
filtered.iter().map(Self::to_lowercase_path).collect();

Ok(files
.iter()
Expand Down
6 changes: 2 additions & 4 deletions lla/src/formatter/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,8 @@ impl FileFormatter for GitFormatter {
let name_width = strip_ansi_codes(&name).width();
let name_padding = " ".repeat(max_name_width.saturating_sub(name_width) as usize);

let hash_padding =
" ".repeat(max_hash_width.saturating_sub(commit_info.0.len()));
let time_padding =
" ".repeat(max_time_width.saturating_sub(commit_info.1.len()));
let hash_padding = " ".repeat(max_hash_width.saturating_sub(commit_info.0.len()));
let time_padding = " ".repeat(max_time_width.saturating_sub(commit_info.1.len()));

let author_part = if commit_info.2 != "-" {
format!("by {} ", commit_info.2.bright_blue())
Expand Down
5 changes: 4 additions & 1 deletion lla/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ impl PluginManager {
match proto::PluginMessage::decode(&response_vec[..]) {
Ok(response_msg) => match response_msg.message {
Some(Message::NameResponse(name)) => {
if let std::collections::hash_map::Entry::Vacant(e) = self.plugins.entry(name) {
if let std::collections::hash_map::Entry::Vacant(
e,
) = self.plugins.entry(name)
{
e.insert((library, api));
self.loaded_paths.insert(path);
}
Expand Down
4 changes: 1 addition & 3 deletions lla/src/sorter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::error::Result;
use std::path::PathBuf;

#[derive(Clone, Copy)]
#[derive(Default)]
#[derive(Clone, Copy, Default)]
pub struct SortOptions {
pub reverse: bool,
pub dirs_first: bool,
pub case_sensitive: bool,
pub natural: bool,
}


pub trait FileSorter: Send + Sync {
fn sort_files(&self, files: &mut [PathBuf], options: SortOptions) -> Result<()>;
}
Expand Down
4 changes: 1 addition & 3 deletions plugins/categorizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ impl Default for CategoryRule {
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Default)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
struct CategoryStats {
count: usize,
total_size: u64,
subcategory_counts: HashMap<String, usize>,
}


pub struct FileCategoryPlugin {
rules: Vec<CategoryRule>,
config_path: PathBuf,
Expand Down

0 comments on commit 4217cee

Please sign in to comment.