class MiGA::Cli::Action::Doctor

@package MiGA @license Artistic-2.0

Public Class Methods

OPERATIONS() click to toggle source

All supported operations

# File lib/miga/cli/action/doctor.rb, line 67
def OPERATIONS
  @@OPERATIONS
end

Public Instance Methods

parse_cli() click to toggle source
# File lib/miga/cli/action/doctor.rb, line 14
def parse_cli
  cli.defaults = { threads: 1 }
  cli.defaults = Hash[@@OPERATIONS.keys.map { |i| [i, true] }]
  cli.parse do |opt|
    operation_n = Hash[@@OPERATIONS.map { |k, v| [v[0], k] }]
    cli.opt_object(opt, [:project])
    opt.on(
      '--ignore TASK1,TASK2', Array,
      'Do not perform the task(s) listed. Available tasks are:',
      * @@OPERATIONS.values.map { |v| "~ #{v[0]}: #{v[1]}" }
    ) { |v| v.map { |i| cli[operation_n[i]] = false } }
    opt.on(
      '--only TASK',
      'Perform only the specified task (see --ignore)'
    ) do |v|
      op_k = @@OPERATIONS.find { |_, i| i[0] == v.downcase }&.first
      op_k or raise "Unknown task: #{v}"
      @@OPERATIONS.each_key { |i| cli[i] = false }
      cli[op_k] = true
    end
    opt.on(
      '-t', '--threads INT', Integer,
      "Concurrent threads to use. By default: #{cli[:threads]}"
    ) { |v| cli[:threads] = v }
  end
end
perform() click to toggle source
# File lib/miga/cli/action/doctor.rb, line 41
def perform
  p = cli.load_project
  @@OPERATIONS.keys.each do |k|
    send("check_#{k}", cli) if cli[k]
  end
end