Skip to content

Commit

Permalink
Merge pull request #90 from chaqchase/feat/improvements-fixes
Browse files Browse the repository at this point in the history
improvements and fixes
  • Loading branch information
chaqchase authored Jan 6, 2025
2 parents 6506342 + 90bd596 commit f7f4a12
Show file tree
Hide file tree
Showing 15 changed files with 619 additions and 113 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@ 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.10] - 2025-01-06

### Added

- Enhanced symlink support:

- New symlink metadata retrieval and display
- Improved symlink target information in output
- Better visual representation of symlinks

- New permission format options:

- `--permission-format` argument with multiple display formats:
- symbolic (default)
- octal
- binary
- verbose
- compact
- Configurable default permission format in settings in configuration file

- Enhanced grid format configuration:
- New `--grid-ignore` option
- Configurable grid width settings in configuration file

### Changed

- Improved plugin configuration with enhanced tilde expansion for plugin directories

- Refined symlink target display positioning in LongFormatter output
- Enhanced documentation and README formatting
- Added completions archive to release workflow

### Fixed

- Fixed symlink handling to respect 'no_symlinks' argument

## [0.3.9] - 2025-01-04

### Added
Expand Down
6 changes: 3 additions & 3 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 @@ -5,7 +5,7 @@ members = ["lla", "lla_plugin_interface", "lla_plugin_utils", "plugins/*"]
[workspace.package]
description = "Blazing Fast and highly customizable ls Replacement with Superpowers"
authors = ["Achaq <hi@achaq.dev>"]
version = "0.3.9"
version = "0.3.10"
categories = ["utilities", "file-system", "cli", "file-management"]
edition = "2021"
license = "MIT"
Expand Down
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<p align="center">
Modern, customizable, feature-rich and extensible `ls` replacement.
<br />
<br />
<a href="https://lla.chaqchase.com">Documentation</a>
·
<a href="#features">Features</a>
Expand Down Expand Up @@ -137,7 +136,8 @@ lla -T
Space-efficient layout for dense directories:

```bash
lla -g
lla -g # Basic grid view
lla -g --grid-ignore # Grid view ignoring terminal width (Warning: may extend beyond screen)
```

<img src="https://github.com/user-attachments/assets/b81d01ea-b830-4833-8791-7b62ff9137df" className="rounded-2xl" alt="grid" />
Expand Down Expand Up @@ -206,13 +206,13 @@ will show a detailed listing of all files and directories in the current directo

#### Basic Views

| Command | Short | Description | Example |
| --------- | ----- | --------------------------------------- | -------- |
| (default) | | List current directory | `lla` |
| `--long` | `-l` | Detailed file information with metadata | `lla -l` |
| `--tree` | `-t` | Hierarchical directory visualization | `lla -t` |
| `--table` | `-T` | Structured data display | `lla -T` |
| `--grid` | `-g` | Organized grid layout | `lla -g` |
| Command | Short | Description | Example |
| --------- | ----- | ----------------------------------------------------------------------------------------------------------------- | -------- |
| (default) | | List current directory | `lla` |
| `--long` | `-l` | Detailed file information with metadata | `lla -l` |
| `--tree` | `-t` | Hierarchical directory visualization | `lla -t` |
| `--table` | `-T` | Structured data display | `lla -T` |
| `--grid` | `-g` | Organized grid layout you can use `-g --grid-ignore` to ignore terminal width (Warning: may extend beyond screen) | `lla -g` |

#### Advanced Views

Expand All @@ -226,11 +226,12 @@ will show a detailed listing of all files and directories in the current directo

#### Display Modifiers

| Command | Description | Example |
| ------------ | ------------------------------------ | ---------------- |
| `--icons` | Show icons for files and directories | `lla --icons` |
| `--no-icons` | Hide icons for files and directories | `lla --no-icons` |
| `--no-color` | Disable all colors in the output | `lla --no-color` |
| Command | Description | Example |
| --------------------- | ------------------------------------------------------------------------------------- | ------------------------------- |
| `--icons` | Show icons for files and directories | `lla --icons` |
| `--no-icons` | Hide icons for files and directories | `lla --no-icons` |
| `--no-color` | Disable all colors in the output | `lla --no-color` |
| `--permission-format` | Set the format for displaying permissions (symbolic, octal, binary, verbose, compact) | `lla --permission-format octal` |

### Sort & Filter Options

Expand Down Expand Up @@ -321,13 +322,15 @@ will show a detailed listing of all files and directories in the current directo

### Configuration & Setup

| Command | Description | Example |
| ------------ | --------------------------------- | --------------------- |
| `init` | Initialize the configuration file | `lla init` |
| `config` | View or modify configuration | `lla config` |
| `theme` | Interactive theme manager | `lla theme` |
| `completion` | Generate shell completion scripts | `lla completion bash` |
| `clean` | Clean up invalid plugins | `lla clean` |
| Command | Description | Example |
| --------------- | --------------------------------- | ------------------------------------------------------------------------------- |
| `init` | Initialize the configuration file | `lla init` |
| `config` | View or modify configuration | `lla config` |
| `theme` | Interactive theme manager | `lla theme` |
| `theme pull` | Pull the built-in themes | `lla theme pull` |
| `theme install` | Install theme from file/directory | `lla theme install /path/to/theme.toml`<br>`lla theme install /path/to/themes/` |
| `completion` | Generate shell completion scripts | `lla completion bash` |
| `clean` | Clean up invalid plugins | `lla clean` |

### General Options

Expand Down
4 changes: 2 additions & 2 deletions lla/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ walkdir.workspace = true
tempfile.workspace = true
users.workspace = true
parking_lot.workspace = true
lla_plugin_interface = { version = "0.3.9", path = "../lla_plugin_interface" }
lla_plugin_utils = { version = "0.3.9", path = "../lla_plugin_utils" }
lla_plugin_interface = { version = "0.3.10", path = "../lla_plugin_interface" }
lla_plugin_utils = { version = "0.3.10", path = "../lla_plugin_utils" }
once_cell.workspace = true
dashmap.workspace = true
unicode-width.workspace = true
Expand Down
22 changes: 22 additions & 0 deletions lla/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Args {
pub tree_format: bool,
pub table_format: bool,
pub grid_format: bool,
pub grid_ignore: bool,
pub sizemap_format: bool,
pub timeline_format: bool,
pub git_format: bool,
Expand All @@ -36,6 +37,7 @@ pub struct Args {
pub no_symlinks: bool,
pub no_dotfiles: bool,
pub dotfiles_only: bool,
pub permission_format: String,
pub command: Option<Command>,
}

Expand Down Expand Up @@ -116,6 +118,11 @@ impl Args {
.long("grid")
.help("Use grid listing format (overrides config format)"),
)
.arg(
Arg::with_name("grid-ignore")
.long("grid-ignore")
.help("Use grid view ignoring terminal width (Warning: output may extend beyond screen width)"),
)
.arg(
Arg::with_name("sizemap")
.short('S')
Expand Down Expand Up @@ -268,6 +275,14 @@ impl Args {
.long("dotfiles-only")
.help("Show only dot files and directories (those starting with a dot)"),
)
.arg(
Arg::with_name("permission-format")
.long("permission-format")
.help("Format for displaying permissions (symbolic, octal, binary, verbose, compact)")
.takes_value(true)
.possible_values(&["symbolic", "octal", "binary", "verbose", "compact"])
.default_value(&config.permission_format),
)
.subcommand(
SubCommand::with_name("install")
.about("Install a plugin")
Expand Down Expand Up @@ -440,6 +455,7 @@ impl Args {
tree_format: config.default_format == "tree",
table_format: config.default_format == "table",
grid_format: config.default_format == "grid",
grid_ignore: false,
sizemap_format: config.default_format == "sizemap",
timeline_format: config.default_format == "timeline",
git_format: config.default_format == "git",
Expand All @@ -466,6 +482,7 @@ impl Args {
no_symlinks: false,
no_dotfiles: config.filter.no_dotfiles,
dotfiles_only: false,
permission_format: config.permission_format.clone(),
command: Some(Command::Shortcut(ShortcutAction::Run(
potential_shortcut.clone(),
args[2..].to_vec(),
Expand Down Expand Up @@ -592,6 +609,7 @@ impl Args {
|| (!has_format_flag && config.default_format == "table"),
grid_format: matches.is_present("grid")
|| (!has_format_flag && config.default_format == "grid"),
grid_ignore: matches.is_present("grid-ignore"),
sizemap_format: matches.is_present("sizemap")
|| (!has_format_flag && config.default_format == "sizemap"),
timeline_format: matches.is_present("timeline")
Expand Down Expand Up @@ -636,6 +654,10 @@ impl Args {
no_symlinks: matches.is_present("no-symlinks"),
no_dotfiles: matches.is_present("no-dotfiles") || config.filter.no_dotfiles,
dotfiles_only: matches.is_present("dotfiles-only"),
permission_format: matches
.value_of("permission-format")
.unwrap_or(&config.permission_format)
.to_string(),
command,
}
}
Expand Down
39 changes: 32 additions & 7 deletions lla/src/commands/file_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::plugin::PluginManager;
use crate::sorter::{AlphabeticalSorter, DateSorter, FileSorter, SizeSorter, SortOptions};
use lla_plugin_interface::proto::{DecoratedEntry, EntryMetadata};
use rayon::prelude::*;
use std::collections::HashMap;
use std::os::unix::fs::MetadataExt;
use std::path::PathBuf;
use std::sync::Arc;
Expand Down Expand Up @@ -148,7 +149,7 @@ pub fn list_and_decorate_files(
)?
.into_par_iter()
.filter_map(|path| {
let fs_metadata = path.metadata().ok()?;
let fs_metadata = path.symlink_metadata().ok()?;
let mut metadata = convert_metadata(&fs_metadata);

let is_dotfile = path
Expand All @@ -168,7 +169,7 @@ pub fn list_and_decorate_files(
} else if args.files_only {
metadata.is_file
} else if args.symlinks_only {
metadata.is_symlink
metadata.is_symlink && !args.no_symlinks
} else {
let include_dirs = !args.no_dirs;
let include_files = !args.no_files;
Expand Down Expand Up @@ -197,10 +198,20 @@ pub fn list_and_decorate_files(
return None;
}

let mut custom_fields = HashMap::new();
if metadata.is_symlink {
if let Ok(target) = std::fs::read_link(&path) {
custom_fields.insert(
"symlink_target".to_string(),
target.to_string_lossy().into_owned(),
);
}
}

Some(DecoratedEntry {
path: path.to_string_lossy().into_owned(),
metadata: Some(metadata),
custom_fields: Default::default(),
custom_fields,
})
})
.collect();
Expand Down Expand Up @@ -314,15 +325,29 @@ fn create_base_filter(pattern: &str, case_insensitive: bool) -> Box<dyn FileFilt

pub fn create_formatter(args: &Args) -> Box<dyn FileFormatter> {
if args.fuzzy_format {
Box::new(FuzzyFormatter::new(args.show_icons))
Box::new(FuzzyFormatter::new(
args.show_icons,
args.permission_format.clone(),
))
} else if args.long_format {
Box::new(LongFormatter::new(args.show_icons))
Box::new(LongFormatter::new(
args.show_icons,
args.permission_format.clone(),
))
} else if args.tree_format {
Box::new(TreeFormatter::new(args.show_icons))
} else if args.table_format {
Box::new(TableFormatter::new(args.show_icons))
Box::new(TableFormatter::new(
args.show_icons,
args.permission_format.clone(),
))
} else if args.grid_format {
Box::new(GridFormatter::new(args.show_icons))
let config = Config::load(&Config::get_config_path()).unwrap_or_default();
Box::new(GridFormatter::new(
args.show_icons,
args.grid_ignore || config.formatters.grid.ignore_width,
config.formatters.grid.max_width,
))
} else if args.sizemap_format {
Box::new(SizeMapFormatter::new(args.show_icons))
} else if args.timeline_format {
Expand Down
Loading

0 comments on commit f7f4a12

Please sign in to comment.