Skip to content

Commit

Permalink
Merge pull request #53 from triyanox/feat/improvements
Browse files Browse the repository at this point in the history
Updates and improvements
  • Loading branch information
chaqchase authored Dec 14, 2024
2 parents 13d6a03 + ccfae5b commit 350db60
Show file tree
Hide file tree
Showing 15 changed files with 1,318 additions and 858 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ 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.2] - 2024-12-14

### Added

- New configuration options like `sort`, `filter`, `icons`

### Changed

- Better error handling
- Better and much cleaner plugins installation process
- Revised config settings
- Refactor the main entry point
- Enhanced plugin update mechanism

### Fixed

- Fixed the layout and style of the plugin installation process

## [0.3.1] - 2024-12-12

### 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.1"
version = "0.3.2"
edition = "2021"
authors = ["Achaq <[email protected]>"]
license = "MIT"
Expand Down
104 changes: 86 additions & 18 deletions 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.1/lla-linux-amd64 -O lla
wget -c https://github.com/triyanox/lla/releases/download/v0.3.2/lla-linux-amd64 -O lla
sudo chmod +x lla
sudo chown root:root lla
sudo mv lla /usr/local/bin/lla
Expand Down Expand Up @@ -351,25 +351,91 @@ The configuration file is located at `~/.config/lla/config.toml`. You can modify
**Configuration File Format:**

```toml
# Core Settings
default_sort = "name" # Possible values: "name", "size", "date"
default_format = "default" # Possible values: "default", "long", "tree", "grid"
enabled_plugins = ["git_status", "file_hash"] # List of enabled plugins
plugins_dir = "/home/user/.config/lla/plugins" # Plugin directory location
default_depth = 3 # Default depth for recursive listing

# Performance Tuning
# LLA Configuration File
# This file controls the behavior and appearance of the lla command

# Default sorting method for file listings
# Possible values:
# - "name": Sort alphabetically by filename (default)
# - "size": Sort by file size, largest first
# - "date": Sort by modification time, newest first
default_sort = "name"

# Default format for displaying files
# Possible values:
# - "default": Quick and clean directory listing
# - "long": Detailed file information with metadata
# - "tree": Hierarchical directory visualization
# - "grid": Organized grid layout for better readability
# - "git": Git-aware view with repository status
# - "timeline": Group files by time periods
# - "sizemap": Visual representation of file sizes
# - "table": Structured data display
default_format = "default"

# Whether to show icons by default
# When true, file and directory icons will be displayed in all views
# Default: false
show_icons = false

# List of enabled plugins
# Each plugin provides additional functionality
# Examples:
# - "git_status": Show Git repository information
# - "file_hash": Calculate and display file hashes
# - "file_tagger": Add and manage file tags
enabled_plugins = []

# Directory where plugins are stored
# Default: ~/.config/lla/plugins
plugins_dir = "~/.config/lla/plugins"

# Maximum depth for recursive directory traversal
# Controls how deep lla will go when showing directory contents
# Set to None for unlimited depth (may impact performance)
# Default: 3 levels deep
default_depth = 3

# Sorting configuration
[sort]
# List directories before files
# Default: false
dirs_first = false

# Enable case-sensitive sorting
# Default: false
case_sensitive = false

# Use natural sorting for numbers (e.g., 2.txt before 10.txt)
# Default: true
natural = true

# Filtering configuration
[filter]
# Enable case-sensitive filtering by default
# Default: false
case_sensitive = false

# Formatter-specific configurations
[formatters.tree]
max_lines = 20000 # Maximum entries in tree view
# Set to 0 for unlimited (may impact performance)
# Maximum number of entries to display in tree view
# Controls memory usage and performance for large directories
# Set to 0 to show all entries (may impact performance)
# Default: 20000 entries
max_lines = 20000

# Lister-specific configurations
[listers.recursive]
max_entries = 20000 # Maximum entries in recursive listing
# Set to 0 for unlimited (may impact performance)

# Command Shortcuts
# Maximum number of entries to process in recursive listing
# Controls memory usage and performance for deep directory structures
# Set to 0 to process all entries (may impact performance)
# Default: 20000 entries
max_entries = 20000

# Command shortcuts
# Define custom shortcuts for frequently used plugin commands
[shortcuts]
find = { plugin_name = "finder", action = "search", description = "Quick file search" }
extract={ plugin_name = "code_snippet_extractor", action = "extract", description = "Extract code snippets"}
```

**Configuration Commands:**
Expand All @@ -384,8 +450,10 @@ lla config # Display current configuration
# Modify settings
lla config --set default_sort size
lla config --set default_format long
lla config --set plugins_dir /custom/path
lla config --set default_depth 5
lla config --set show_icons true
lla config --set sort.dirs_first true
lla config --set sort.case_sensitive true
lla config --set filter.case_sensitive true

# Manage shortcuts
lla shortcut add NAME PLUGIN ACTION [-d DESCRIPTION] # Add shortcut
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.1", path = "../lla_plugin_interface" }
lla_plugin_interface = { version = "0.3.2", path = "../lla_plugin_interface" }
once_cell.workspace = true
dashmap.workspace = true
unicode-width.workspace = true
Expand Down
96 changes: 55 additions & 41 deletions lla/src/args.rs → lla/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum ShortcutAction {
Run(String, Vec<String>),
}

#[derive(Clone)]
pub enum ConfigAction {
View,
Set(String, String),
Expand All @@ -63,22 +64,22 @@ impl Args {
if config.get_shortcut(potential_shortcut).is_some() {
return Self {
directory: ".".to_string(),
depth: None,
long_format: false,
tree_format: false,
table_format: false,
grid_format: false,
sizemap_format: false,
timeline_format: false,
git_format: false,
show_icons: false,
sort_by: "name".to_string(),
depth: config.default_depth,
long_format: config.default_format == "long",
tree_format: config.default_format == "tree",
table_format: config.default_format == "table",
grid_format: config.default_format == "grid",
sizemap_format: config.default_format == "sizemap",
timeline_format: config.default_format == "timeline",
git_format: config.default_format == "git",
show_icons: config.show_icons,
sort_by: config.default_sort.clone(),
sort_reverse: false,
sort_dirs_first: false,
sort_case_sensitive: false,
sort_natural: false,
sort_dirs_first: config.sort.dirs_first,
sort_case_sensitive: config.sort.case_sensitive,
sort_natural: config.sort.natural,
filter: None,
case_sensitive: false,
case_sensitive: config.filter.case_sensitive,
enable_plugin: Vec::new(),
disable_plugin: Vec::new(),
plugins_dir: config.plugins_dir.clone(),
Expand All @@ -105,53 +106,58 @@ impl Args {
.short('d')
.long("depth")
.takes_value(true)
.help("Set the depth for tree listing"),
.help("Set the depth for tree listing (default from config)"),
)
.arg(
Arg::with_name("long")
.short('l')
.long("long")
.help("Use long listing format"),
.help("Use long listing format (overrides config format)"),
)
.arg(
Arg::with_name("tree")
.short('t')
.long("tree")
.help("Use tree listing format"),
.help("Use tree listing format (overrides config format)"),
)
.arg(
Arg::with_name("table")
.short('T')
.long("table")
.help("Use table listing format"),
.help("Use table listing format (overrides config format)"),
)
.arg(
Arg::with_name("grid")
.short('g')
.long("grid")
.help("Use grid listing format"),
.help("Use grid listing format (overrides config format)"),
)
.arg(
Arg::with_name("sizemap")
.short('S')
.long("sizemap")
.help("Show visual representation of file sizes"),
.help("Show visual representation of file sizes (overrides config format)"),
)
.arg(
Arg::with_name("timeline")
.long("timeline")
.help("Group files by time periods"),
.help("Group files by time periods (overrides config format)"),
)
.arg(
Arg::with_name("git")
.short('G')
.long("git")
.help("Show git status and information"),
.help("Show git status and information (overrides config format)"),
)
.arg(
Arg::with_name("icons")
.long("icons")
.help("Show icons for files and directories"),
.help("Show icons for files and directories (overrides config setting)"),
)
.arg(
Arg::with_name("no-icons")
.long("no-icons")
.help("Hide icons for files and directories (overrides config setting)"),
)
.arg(
Arg::with_name("sort")
Expand All @@ -170,17 +176,17 @@ impl Args {
.arg(
Arg::with_name("sort-dirs-first")
.long("sort-dirs-first")
.help("List directories before files"),
.help("List directories before files (overrides config setting)"),
)
.arg(
Arg::with_name("sort-case-sensitive")
.long("sort-case-sensitive")
.help("Enable case-sensitive sorting"),
.help("Enable case-sensitive sorting (overrides config setting)"),
)
.arg(
Arg::with_name("sort-natural")
.long("sort-natural")
.help("Use natural sorting for numbers (e.g., 2.txt before 10.txt)"),
.help("Use natural sorting for numbers (overrides config setting)"),
)
.arg(
Arg::with_name("filter")
Expand All @@ -193,7 +199,7 @@ impl Args {
Arg::with_name("case-sensitive")
.short('c')
.long("case-sensitive")
.help("Enable case-sensitive filtering"),
.help("Enable case-sensitive filtering (overrides config setting)"),
)
.arg(
Arg::with_name("enable-plugin")
Expand Down Expand Up @@ -403,22 +409,30 @@ impl Args {

Args {
directory: matches.value_of("directory").unwrap_or(".").to_string(),
depth: matches.value_of("depth").and_then(|s| s.parse().ok()),
long_format: matches.is_present("long"),
tree_format: matches.is_present("tree"),
table_format: matches.is_present("table"),
grid_format: matches.is_present("grid"),
sizemap_format: matches.is_present("sizemap"),
timeline_format: matches.is_present("timeline"),
git_format: matches.is_present("git"),
show_icons: matches.is_present("icons"),
sort_by: matches.value_of("sort").unwrap_or("name").to_string(),
depth: matches
.value_of("depth")
.and_then(|s| s.parse().ok())
.or(config.default_depth),
long_format: matches.is_present("long") || config.default_format == "long",
tree_format: matches.is_present("tree") || config.default_format == "tree",
table_format: matches.is_present("table") || config.default_format == "table",
grid_format: matches.is_present("grid") || config.default_format == "grid",
sizemap_format: matches.is_present("sizemap") || config.default_format == "sizemap",
timeline_format: matches.is_present("timeline") || config.default_format == "timeline",
git_format: matches.is_present("git") || config.default_format == "git",
show_icons: matches.is_present("icons")
|| (!matches.is_present("no-icons") && config.show_icons),
sort_by: matches
.value_of("sort")
.unwrap_or(&config.default_sort)
.to_string(),
sort_reverse: matches.is_present("sort-reverse"),
sort_dirs_first: matches.is_present("sort-dirs-first"),
sort_case_sensitive: matches.is_present("sort-case-sensitive"),
sort_natural: matches.is_present("sort-natural"),
sort_dirs_first: matches.is_present("sort-dirs-first") || config.sort.dirs_first,
sort_case_sensitive: matches.is_present("sort-case-sensitive")
|| config.sort.case_sensitive,
sort_natural: matches.is_present("sort-natural") || config.sort.natural,
filter: matches.value_of("filter").map(String::from),
case_sensitive: matches.is_present("case-sensitive"),
case_sensitive: matches.is_present("case-sensitive") || config.filter.case_sensitive,
enable_plugin: matches
.values_of("enable-plugin")
.map(|v| v.map(String::from).collect())
Expand Down
Loading

0 comments on commit 350db60

Please sign in to comment.