Module: BundleSafeUpdate::CLI::Options

Included in:
BundleSafeUpdate::CLI
Defined in:
lib/bundle_safe_update/cli/options.rb

Instance Method Summary collapse

Instance Method Details

#build_option_parser(options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/bundle_safe_update/cli/options.rb', line 6

def build_option_parser(options)
  OptionParser.new do |opts|
    opts.banner = 'Usage: bundle-safe-update [options] [gem1 gem2 ...]'
    define_config_options(opts, options)
    define_output_options(opts, options)
    define_info_options(opts)
  end
end

#define_basic_config_options(opts, options) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/bundle_safe_update/cli/options.rb', line 20

def define_basic_config_options(opts, options)
  opts.on('--config PATH', 'Path to config file') { |path| options[:config] = path }
  opts.on('--cooldown DAYS', Integer, 'Minimum age in days') { |days| options[:cooldown] = days }
  opts.on('--update', 'Update gems that pass the cooldown check') { options[:update] = true }
  opts.on('--lock-only', 'Update Gemfile.lock without installing gems') { options[:lock_only] = true }
  opts.on('--warn-only', 'Report violations but exit with success') { options[:warn_only] = true }
  opts.on('--dry-run', 'Show configuration without checking') { options[:dry_run] = true }
end

#define_config_options(opts, options) ⇒ Object



15
16
17
18
# File 'lib/bundle_safe_update/cli/options.rb', line 15

def define_config_options(opts, options)
  define_basic_config_options(opts, options)
  define_skip_options(opts, options)
end

#define_info_options(opts) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/bundle_safe_update/cli/options.rb', line 40

def define_info_options(opts)
  opts.on('-v', '--version', 'Show version') do
    puts("bundle-safe-update #{VERSION}")
    exit(EXIT_SUCCESS)
  end
  opts.on('-h', '--help', 'Show this help') do
    puts(opts)
    exit(EXIT_SUCCESS)
  end
end

#define_output_options(opts, options) ⇒ Object



35
36
37
38
# File 'lib/bundle_safe_update/cli/options.rb', line 35

def define_output_options(opts, options)
  opts.on('--json', 'Output in JSON format') { options[:json] = true }
  opts.on('--verbose', 'Enable verbose output') { options[:verbose] = true }
end

#define_skip_options(opts, options) ⇒ Object



29
30
31
32
33
# File 'lib/bundle_safe_update/cli/options.rb', line 29

def define_skip_options(opts, options)
  opts.on('--no-audit', 'Skip vulnerability audit') { options[:audit] = false }
  opts.on('--no-risk', 'Skip risk signal checking') { options[:risk] = false }
  opts.on('--refresh-cache', 'Refresh owner cache without warnings') { options[:refresh_cache] = true }
end