Skip to content

Add rails-stats command line executable#49

Merged
etagwerker merged 5 commits into
mainfrom
add-rails-stats-executable
Jul 12, 2026
Merged

Add rails-stats command line executable#49
etagwerker merged 5 commits into
mainfrom
add-rails-stats-executable

Conversation

@etagwerker

Copy link
Copy Markdown
Member
  • Add an entry to CHANGELOG.md that links to this PR under the "main (unreleased)" heading.

Description:

This adds a standalone rails-stats executable so the tool can be run against a directory without having to set up a Rakefile first.

Before, running against an arbitrary directory required a Rakefile and the rake stats[/path/to/app/] invocation. Now you can just call:

$ rails-stats /path/to/app   # absolute path
$ rails-stats path/to/app    # relative path
$ rails-stats                # defaults to the current directory
$ rails-stats path/to/app json  # JSON output

The executable resolves the path with File.absolute_path, so both absolute and relative paths work, prints the resolved directory, and exits with a friendly error (exit code 1) when the directory does not exist. It calls RailsStats::CodeStatistics directly instead of going through Rake.

The gemspec already ships anything under bin/ as an executable (spec.executables = spec.files.grep(%r{^bin/})), so no gemspec change was needed.

README gains a "Run it as a command line tool" section documenting the usage.

I will abide by the code of conduct.

🤖 Generated with Claude Code

Add a standalone `rails-stats` executable so the tool can be run against a
directory without setting up a Rakefile. It accepts both absolute and relative
paths, defaults to the current directory when none is given, and optionally
takes a `json` second argument for JSON output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@etagwerker
etagwerker force-pushed the add-rails-stats-executable branch from d90b473 to c63c5ba Compare July 12, 2026 14:07
etagwerker and others added 2 commits July 12, 2026 10:19
Set spec.bindir/spec.executables explicitly in the gemspec per the RubyGems
specification reference, and update the README so the primary usage examples
call the rails-stats executable instead of rake stats[...].

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a standalone rails-stats command-line executable so RailsStats can be run against any directory without needing a local Rakefile, and updates documentation/changelog accordingly.

Changes:

  • Add bin/rails-stats CLI entrypoint that resolves a target directory and runs RailsStats::CodeStatistics directly.
  • Update README usage examples to document the CLI and replace some rake stats[...] examples with rails-stats ....
  • Update gemspec executable metadata and add a changelog entry linking to this PR.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
README.md Documents the new CLI usage and updates examples to prefer rails-stats.
rails_stats.gemspec Updates gem metadata and sets executable/bindir configuration for the new CLI.
CHANGELOG.md Adds an unreleased feature entry linking to PR #49.
bin/rails-stats New standalone CLI wrapper around RailsStats::CodeStatistics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.md

```bash
$ for dir in /path/to/many/engines/*/; do bundle exec rake stats[$dir]; done
$ for dir in /path/to/many/engines/*/; do rails-stats "$dir"; done
Comment thread rails_stats.gemspec
Comment on lines +17 to +18
spec.bindir = "bin"
spec.executables = ["rails-stats"]
Move all rake invocation instructions (Rakefile-in-any-directory and
replacing the built-in rake stats inside a Rails app) into a single
"Calling it through rake" subsection, and switch every other example to
the rails-stats executable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@etagwerker
etagwerker marked this pull request as ready for review July 12, 2026 14:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@etagwerker
etagwerker merged commit 4c303da into main Jul 12, 2026
8 checks passed
@etagwerker
etagwerker deleted the add-rails-stats-executable branch July 12, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants