update to modern tooling
This commit is contained in:
43
CLAUDE.md
Normal file
43
CLAUDE.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# 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/`.
|
||||
11
go.mod
Normal file
11
go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module github.com/amyboyd/editorconfig-cli
|
||||
|
||||
go 1.25.0
|
||||
|
||||
require (
|
||||
github.com/codegangsta/cli v1.20.0
|
||||
github.com/go-ini/ini v1.67.0
|
||||
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d
|
||||
)
|
||||
|
||||
require github.com/stretchr/testify v1.10.0 // indirect
|
||||
14
go.sum
Normal file
14
go.sum
Normal file
@@ -0,0 +1,14 @@
|
||||
github.com/codegangsta/cli v1.20.0 h1:iX1FXEgwzd5+XN6wk5cVHOGQj6Q3Dcp20lUeS4lHNTw=
|
||||
github.com/codegangsta/cli v1.20.0/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d h1:hrujxIzL1woJ7AwssoOcM/tq5JjjG2yYOc8odClEiXA=
|
||||
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
Reference in New Issue
Block a user