Code Monkey home page Code Monkey logo

lla's Introduction

lla - Advanced File Listing Utility

lla is a high-performance, extensible alternative to the traditional ls command, written in Rust. It offers enhanced functionality, customizable output, and a plugin system for extended capabilities.

lla in action

Features

  • Efficient file listing: Optimized for speed, even in large directories
  • Multiple view modes:
    • Default view
    • Long format (-l)
    • Tree view (-t)
    • Recursive listing (-R)
  • Advanced sorting:
    • Alphabetical (default)
    • File size (-s size)
    • Modification date (-s date)
  • Flexible filtering: Filter by filename or extension (-f, --filter)
  • Customizable recursion: Set maximum depth for subdirectory traversal
  • Extensible plugin system: Develop and integrate custom functionality
  • Color-coded output: Easily distinguish file types and permissions
  • Git integration: Show git status for files (with plugin)
  • File categorization: Categorize files by type (with plugin)
  • Keyword search: Search file contents for specified keywords (with plugin)
  • File hash display: Show file hashes (with plugin)
  • Code complexity analysis: Analyze code complexity (with plugin)
  • File size visualization: Visualize file sizes (with plugin)
  • Duplicate file detection: Identify duplicate files (with plugin)
  • Directory metadata: Display detailed directory information (with plugin)
  • File metadata: Show extended file metadata (with plugin)
  • Last git commit info: Display information about the last git commit (with plugin)

and more!

Installation

From crates.io

cargo install lla

For NetBSD users

pkgin install lla

(we see you, netbsd. we appreciate you.)

Usage

First you need to initialize the configuration file:

lla init

Then you can start using lla:

lla [OPTIONS] [DIRECTORY]

Core Options

  • -l, --long: Use long listing format
  • -R, --recursive: List subdirectories recursively
  • -t, --tree: Display files in a tree structure
  • -s, --sort <CRITERIA>: Sort by "name", "size", or "date"
  • -f, --filter <PATTERN>: Filter files by name or extension
  • -d, --depth <DEPTH>: Set maximum recursion depth

Plugin Management

  • --enable-plugin <NAME>: Enable a specific plugin
  • --disable-plugin <NAME>: Disable a specific plugin
  • --plugins-dir <PATH>: Specify custom plugins directory
  • --plugin-arg <ARG>: Pass arguments to enabled plugins

Plugin Actions

lla supports plugin-specific actions, allowing you to interact with plugins directly:

lla plugin --name <PLUGIN_NAME> --action <ACTION_NAME> [--args <ARG1> <ARG2> ...]
  • --name <PLUGIN_NAME>: Specify the name of the plugin
  • --action <ACTION_NAME>: Specify the action to perform
  • --args <ARG1> <ARG2> ...: Provide arguments for the action (optional)

Utility Commands

  • lla install: Install plugins
    • --git <URL>: Install from a Git repository
    • --dir <PATH>: Install from a local directory
  • lla list-plugins: Display all available plugins
  • lla init: Initialize configuration file

Configuration

lla uses a TOML configuration file located at ~/.config/lla/config.toml. Initialize with default settings:

lla init

Example configuration:

default_sort = "name"
default_format = "default"
enabled_plugins = ["git_status", "file_hash"]
plugins_dir = "/home/user/.config/lla/plugins"
default_depth = 3

Install Plugins

You can install plugins from a local directory or from a Git repository.

You can find official plugins here.

From Git

lla install --git <github_url>

From Local Directory

lla install --dir <path>

Plugin Development

Develop custom plugins to extend lla's functionality. Plugins are dynamic libraries that implement the Plugin trait from the lla_plugin_interface crate.

Plugin Structure

  1. Create a new Rust library:

    cargo new --lib my_lla_plugin
  2. Add dependencies to Cargo.toml:

    [dependencies]
    lla_plugin_interface = "*"
    
    [lib]
    crate-type = ["cdylib"]
  3. Implement the Plugin trait:

use lla_plugin_interface::{Plugin, DecoratedEntry, EntryDecorator, CliArg};

pub struct MyPlugin;

impl Plugin for MyPlugin {
    fn name(&self) -> &'static str {
        "my_plugin"
    }

    fn version(&self) -> &'static str {
        env!("CARGO_PKG_VERSION")
    }

    fn description(&self) -> &'static str {
        env!("CARGO_PKG_DESCRIPTION")
    }

    fn cli_args(&self) -> Vec<CliArg> {
        vec![
            CliArg {
                name: "my-option".to_string(),
                short: Some('m'),
                long: Some("my-option".to_string()),
                help: "Description of my option".to_string(),
                takes_value: true,
            }
        ]
    }

    fn handle_cli_args(&self, args: &[String]) {
        // Handle CLI arguments passed to the plugin
    }

    fn perform_action(&self, action: &str, args: &[String]) -> Result<(), String> {
        match action {
            "my-action" => {
                // Perform custom action
                Ok(())
            }
            _ => Err(format!("Unknown action: {}", action)),
        }
    }
}

impl EntryDecorator for MyPlugin {
    fn decorate(&self, entry: &mut DecoratedEntry) {
        // Add custom fields or modify entry
    }

    fn format_field(&self, entry: &DecoratedEntry, format: &str) -> Option<String> {
        // Return formatted string for display
    }

    fn supported_formats(&self) -> Vec<&'static str> {
        vec!["default", "long", "tree"]
    }
}

lla_plugin_interface::declare_plugin!(MyPlugin);
  1. Build your plugin:

    cargo build --release
  2. Install the plugin:

    lla install --dir /path/to/my_lla_plugin

    or

    lla install --git <git_repo>

Plugin Interface

The lla_plugin_interface crate provides the following key components:

  • Plugin trait: Core interface for plugin functionality
  • EntryDecorator trait: Methods for decorating and formatting file entries
  • DecoratedEntry struct: Represents a file entry with metadata and custom fields
  • CliArg struct: Defines command-line arguments for the plugin

Examples

# Long format, sorted by size, showing only .rs files
lla -ls size -f .rs

# Enable git status plugin
lla --enable-plugin git_status

# Enable multiple plugins
lla --enable-plugin git_status categorizer

# Disable git status plugin
lla --disable-plugin git_status

# Disable multiple plugins
lla --disable-plugin git_status categorizer

# Set keywords for the keyword search plugin using plugin action
lla plugin --name keyword_search --action set-keywords --args "TODO" "FIXME" "BUG"

# Show current keywords for the keyword search plugin
lla plugin --name keyword_search --action show-keywords

# Use the keyword search plugin with the set keywords
lla --enable-plugin keyword_search

Contributing

Contributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -m 'Add some new-feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

lla's People

Contributors

0323pin avatar triyanox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lla's Issues

Github release tags

Hi,

Did you stop providing Github release tags?
I've changed the source to crates.io but, in order to maintain the package up-to-date, it's better with tags here. Github provides RSS feeds that I can use, something that crates.io does not, AFAIK.

Regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.