summaryrefslogtreecommitdiff
path: root/lib/options.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-06 23:52:43 +0200
committerPaul Buetow <paul@buetow.org>2024-12-06 23:52:43 +0200
commit7c23b27007ca62ff545411aa3d1200fce4eec8c9 (patch)
tree86e4215580368b5c6f164bb79c2a0f91f479c7f1 /lib/options.rb
parent36c00a4509e745e4b29b1194faca4dca830a9b95 (diff)
refactor
Diffstat (limited to 'lib/options.rb')
-rw-r--r--lib/options.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/options.rb b/lib/options.rb
new file mode 100644
index 0000000..c3950ca
--- /dev/null
+++ b/lib/options.rb
@@ -0,0 +1,23 @@
+require 'optparse'
+
+module RCM
+ # Command line options
+ module Options
+ @@options = {
+ debug: 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-]debug', 'debug output') { |v| @@options[:debug] = v }
+ end.parse!(after_double_dash)
+
+ def option(key)
+ raise "No such option: #{key}" unless @@options.key?(key)
+
+ @@options[key]
+ end
+ end
+end