43 lines
2.3 KiB
Markdown
43 lines
2.3 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
This is a Go CLI tool for validating and fixing files according to .editorconfig rules. The tool provides four main commands: `check`, `fix`, `ls`, and `rules`.
|
|
|
|
## Development Commands
|
|
|
|
- **Build**: `go build -o editorconfig-cli .` (creates single binary)
|
|
- **Run tests**: `go test ./editorconfig`
|
|
- **Cross-platform build**: Use `bin/build` script (requires fixing Go path)
|
|
- **Test the CLI**:
|
|
- `./editorconfig-cli check [paths]` - validate files
|
|
- `./editorconfig-cli fix [paths]` - fix files
|
|
- `./editorconfig-cli ls [paths]` - list matched files
|
|
- `./editorconfig-cli rules [paths]` - show rules for files
|
|
|
|
## Modern Setup
|
|
|
|
This project has been modernized with Go modules. The original `bin/build` script uses a hardcoded Go path (`/usr/local/go/bin/go`) that may not exist on modern systems. Use `go build` directly instead.
|
|
|
|
## Architecture
|
|
|
|
The main application entry point is in `main.go`, which delegates to the CLI app created in `editorconfig/cli.go`. The core functionality is organized into:
|
|
|
|
- **Command handlers**: `*_command.go` files implement the four main CLI commands
|
|
- **Rule processing**: `line_checkers.go`, `line_fixers.go`, `full_file_checkers.go`, `full_file_fixers.go` contain the validation and fixing logic
|
|
- **File discovery**: `source_file_finder.go` handles finding files to process
|
|
- **Configuration**: `config_file_finder.go` and `config_file.go` handle .editorconfig file parsing
|
|
- **Path matching**: `path_matcher.go` implements glob pattern matching for .editorconfig sections
|
|
|
|
## Key Implementation Details
|
|
|
|
- The project uses the `github.com/codegangsta/cli` library for command-line interface
|
|
- Rules are applied based on .editorconfig files found in the directory hierarchy
|
|
- The tool supports standard .editorconfig properties: `indent_style`, `indent_size`, `tab_width`, `end_of_line`, `charset`, `trim_trailing_whitespace`, `insert_final_newline`
|
|
- File pattern matching supports most glob patterns, with some limitations documented in `path_matcher.go`
|
|
|
|
## Testing
|
|
|
|
All Go packages have corresponding `*_test.go` files. The test suite includes both unit tests and integration tests using sample files in `editorconfig/tests/`. |