ls-plus 0.0.1

Enhanced ls command with modern features - supports both cargo and npm installation
# ls-plus

使用 Rust 编写的增强版 `ls` 命令,提供现代化功能,支持双包管理系统安装。

## 功能特性

- 🚀 **快速高效** - 使用 Rust 构建,性能卓越
- 🎨 **美观输出** - 彩色输出与文件类型指示器
- 📁 **多种格式** - 支持不同显示格式(默认、详细、树形、网格、JSON)
- 🔍 **智能过滤** - 按文件类型过滤,模式匹配
- 🌳 **树形视图** - 层次化目录可视化
- ⚙️ **可配置** - 持久化配置,合理默认值
- 📊 **Git 集成** - 显示文件的 git 状态(可选)
- 🎯 **搜索功能** - 模式匹配查找文件
- 📦 **双包管理** - 同时支持 Cargo 和 npm 安装

## 安装

### Option 1: 通过 npm 安装(推荐)

适合 Node.js 开发者,无需安装 Rust 环境:

```bash
# 全局安装
npm install -g @atom/ls-plus

# 使用命令
lsp --help
```

### Option 2: 通过 Cargo 安装

适合 Rust 开发者:

```bash
cargo install ls-plus
```

### Option 3: 从源码安装

```bash
git clone https://github.com/oppenheimor/ls-plus.git
cd ls-plus

# 方式 1: 使用 npm(自动处理 Rust 构建)
npm install

# 方式 2: 直接使用 Cargo
cargo build --release
```

## 环境要求

### npm 安装
- Node.js 14+ 
- 无需 Rust 环境(自动下载预构建二进制)

### Cargo 安装
- Rust 1.74 或更新版本
- Git(可选,用于 git 集成功能)

## 使用方法

### 基本用法

```bash
# npm 安装用户使用 lsp 命令
lsp

# Cargo 安装用户使用 ls-plus 命令  
ls-plus

# 列出指定目录
lsp /path/to/directory
ls-plus /path/to/directory

# 显示所有文件(包括隐藏文件)
ls-plus -a

# 详细格式显示
ls-plus -l

# 人类可读的文件大小
ls-plus -h

# 按修改时间排序
ls-plus -t

# 逆序排列
ls-plus -r

# 目录优先显示
ls-plus --directories-first

# 显示文件图标
ls-plus --icons

# 强制开启/关闭颜色
ls-plus --color always
ls-plus --color never
```

### 高级功能

```bash
# 树形视图
ls-plus tree /path/to/directory

# 限制树形深度
ls-plus tree -d 3 /path/to/directory

# 不同输出格式
ls-plus --format long
ls-plus --format tree
ls-plus --format grid
ls-plus --format json

# 按文件类型过滤
ls-plus --file-type dir     # 仅目录
ls-plus --file-type file    # 仅文件
ls-plus --file-type image   # 仅图像文件

# 搜索文件
ls-plus find 模式 /搜索路径

# Git 集成
ls-plus --git
```

### 配置管理

```bash
# 显示当前配置
ls-plus config show

# 设置配置值
ls-plus config set display.show_icons true
ls-plus config set display.color_mode always
ls-plus config set behavior.directories_first true

# 重置为默认值
ls-plus config reset

# 编辑配置文件
ls-plus config edit
```

## 配置文件

配置文件位置:
- **Linux/macOS**: `~/.config/ls-plus/config.toml`
- **Windows**: `%APPDATA%/ls-plus/config.toml`

### 配置示例

```toml
[display]
default_format = "Default"
color_mode = "Auto"
show_icons = false
human_readable_sizes = true
directories_first = true
show_hidden = false

[behavior]
follow_symlinks = false
git_integration = false
max_depth = null
sort_by_time = false
reverse_sort = false

[icons]
enable_icons = false
icon_theme = "default"

[colors]
file_colors = true
size_colors = true
time_colors = true
permission_colors = true
```

## 开发

### 构建

```bash
# 调试构建
cargo build

# 发布构建
cargo build --release

# 运行测试
cargo test

# 带日志运行
RUST_LOG=debug cargo run -- /测试路径
```

### 测试

```bash
# 运行所有测试
cargo test

# 运行特定测试
cargo test test_basic_help

# 运行集成测试
cargo test --test integration_test
```

### 代码质量

```bash
# 格式化代码
cargo fmt

# 代码检查
cargo clippy

# 安全审计
cargo audit
```

## 双包架构说明

本项目采用创新的双包管理架构,同时支持 Rust 和 Node.js 生态:

### 🦀 Rust 包 (Cargo)
- **包名**: `ls-plus`
- **命令**: `ls-plus`
- **安装**: `cargo install ls-plus`
- **适用**: Rust 开发者,系统管理员

### 📦 Node.js 包 (npm)
- **包名**: `@atom/ls-plus`
- **命令**: `lsp`
- **安装**: `npm install -g @atom/ls-plus`
- **适用**: 前端开发者,Node.js 用户

### 技术实现

1. **智能安装脚本**: 自动检测环境,优先本地构建,回退到预构建二进制
2. **跨平台支持**: 自动检测操作系统和架构,下载对应的二进制文件
3. **统一功能**: 两种安装方式提供完全相同的功能和命令选项
4. **开发友好**: 开发环境自动构建,生产环境使用预构建二进制

## 项目结构

```
src/
├── main.rs          # 应用程序入口
├── cli.rs           # 命令行接口定义
├── config.rs        # 配置管理
├── display.rs       # 输出格式化和渲染
├── error.rs         # 错误类型和处理
├── fs.rs            # 文件系统操作
└── git.rs           # Git 集成
bin/
└── lsp              # npm 包命令行入口
tests/
└── integration_test.rs  # 集成测试
package.json         # npm 包配置
Cargo.toml          # Rust 包配置
install.js          # npm 智能安装脚本
index.js            # npm 包主入口
```

## 贡献

1. Fork 仓库
2. 创建功能分支
3. 进行修改
4. 为新功能添加测试
5. 运行测试套件
6. 提交 Pull Request

## 许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

## 路线图

- [ ] 自定义格式化器插件系统
- [ ] 云存储提供商集成
- [ ] 正则表达式高级搜索
- [ ] 性能基准测试工具
- [ ] Shell 自动补全脚本
- [ ] Man 页面生成
- [ ] Windows 特定优化
- [ ] 多语言支持