diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-03-15 13:55:47 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-03-15 13:55:47 +0900 |
| commit | f0826057350555f802d5e27a26b6b91510182ccb (patch) | |
| tree | 958534b2bccda25f662faee6741c40485c8c3bfb | |
| parent | a1ced60692022184d40bdbb980131705e6be4fda (diff) | |
outdate-bundled-gems.rb: Add `--help` option
| -rwxr-xr-x | tool/outdate-bundled-gems.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tool/outdate-bundled-gems.rb b/tool/outdate-bundled-gems.rb index 68adb3d7dc..5422aec454 100755 --- a/tool/outdate-bundled-gems.rb +++ b/tool/outdate-bundled-gems.rb @@ -3,34 +3,52 @@ require 'fileutils' require 'rubygems' fu = FileUtils::Verbose + until ARGV.empty? case ARGV.first when '--' ARGV.shift break when '-n', '--dryrun' + ## -n, --dryrun Don't remove fu = FileUtils::DryRun when /\A--make=/ # just to run when `make -n` when /\A--mflags=(.*)/ fu = FileUtils::DryRun if /\A-\S*n/ =~ $1 when /\A--gem[-_]platform=(.*)/im + ## --gem-platform=PLATFORM Platform in RubyGems style gem_platform = $1 ruby_platform = nil when /\A--ruby[-_]platform=(.*)/im + ## --ruby-platform=PLATFORM Platform in Ruby style ruby_platform = $1 gem_platform = nil when /\A--ruby[-_]version=(.*)/im + ## --ruby-version=VERSION Ruby version to keep ruby_version = $1 when /\A--only=(?:(curdir|srcdir)|all)\z/im + ## --only=(curdir|srcdir|all) Specify directory to remove gems from only = $1&.downcase when /\A--all\z/im + ## --all Remove all gems not only bundled gems all = true + when /\A--help\z/im + ## --help Print this message + puts "Usage: #$0 [options] [srcdir]" + File.foreach(__FILE__) do |line| + line.sub!(/^ *## /, "") or next + break if line.chomp!.empty? + opt, desc = line.split(/ {2,}/, 2) + printf " %-28s %s\n", opt, desc + end + exit when /\A-/ raise "#{$0}: unknown option: #{ARGV.first}" else break end + ## ARGV.shift end |
