Module: UltraCommandLine::Commands::Validation

Included in:
SubCommand
Defined in:
lib/ultra_command_line/commands/validation.rb

Instance Method Summary collapse

Instance Method Details

#valid?(raise_error: false) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ultra_command_line/commands/validation.rb', line 7

def valid?(raise_error: false)
  # return false_or_raise 'You have to successfully parse cmd line parameters before checking its validity !', raise_error: raise_error  if params_hash.nil?
  begin
    raise if params_hash.nil?
  rescue
    return false_or_raise 'You have to successfully parse cmd line parameters before checking its validity !', raise_error: raise_error
  end
  return false unless check_options_dependencies raise_error: raise_error
  return false unless check_options_incompatibilities raise_error: raise_error
  if name.empty?
    unless root_command?
      return false_or_raise 'Only a root command should not have a name !', raise_error: raise_error
    end
  end
  true
end