diff options
| author | Paul Buetow <paul@buetow.org> | 2024-12-06 22:33:07 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-12-06 22:33:07 +0200 |
| commit | bfdcad7efca071374de0be3124dcc92deeab681e (patch) | |
| tree | 6215f6fcf5287f69840d06ad8c009dab0945ef6d /lib/autorequire/options.rb | |
| parent | 4a3629e42cb3e1fbca4356cf789a8e79043cdc51 (diff) | |
auto require
Diffstat (limited to 'lib/autorequire/options.rb')
| -rw-r--r-- | lib/autorequire/options.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/autorequire/options.rb b/lib/autorequire/options.rb new file mode 100644 index 0000000..de54888 --- /dev/null +++ b/lib/autorequire/options.rb @@ -0,0 +1,23 @@ +require 'optparse' + +module RCM + # Command line options + module Options + @@options = { + verbose: false + } + + after_double_dash = ARGV.slice_before('--').to_a.last.drop(1) + + OptionParser.new do |opts| + opts.banner = 'Usage: rake [task] -- [options]' + opts.on('-v', '--[no-]verbose', 'run verbosely') { |v| @@options[:verbose] = v } + end.parse!(after_double_dash) + + def option(key) + raise "No such option: #{key}" unless @@options.key?(key) + + @@options[key] + end + end +end |
