Class: Commander::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/MrMurano/ReCommander.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#must_not_be_managedObject

A command sets must_not_be_managed if its use is restricted to unmanaged solutions.



57
58
59
# File 'lib/MrMurano/ReCommander.rb', line 57

def must_not_be_managed
  @must_not_be_managed
end

#project_not_requiredObject

A command sets project_not_required if it can run from without a project directory.



45
46
47
# File 'lib/MrMurano/ReCommander.rb', line 45

def project_not_required
  @project_not_required
end

#prompt_if_logged_offObject

A command sets prompt_if_logged_off if it is okay to ask the user for their password.



52
53
54
# File 'lib/MrMurano/ReCommander.rb', line 52

def prompt_if_logged_off
  @prompt_if_logged_off
end

#restrict_to_cur_dirObject

A command sets restrict_to_cur_dir if it should not climb the directory hierarchy in search of a .murano/config file.



49
50
51
# File 'lib/MrMurano/ReCommander.rb', line 49

def restrict_to_cur_dir
  @restrict_to_cur_dir
end

#subcmdgrouphelpObject

A command sets subcmdgrouphelp if it’s help.



54
55
56
# File 'lib/MrMurano/ReCommander.rb', line 54

def subcmdgrouphelp
  @subcmdgrouphelp
end

Instance Method Details

#verify_arg_count!(args, max_args = 0, mandatory = []) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/MrMurano/ReCommander.rb', line 59

def verify_arg_count!(args, max_args=0, mandatory=[])
  if !max_args.nil? && max_args.zero?
    if args.count > 0
      MrMurano::Verbose.error('Not expecting any arguments')
      exit 2
    end
  elsif !max_args.nil? && args.count > max_args
    MrMurano::Verbose.error("Not expecting more than #{max_args} arguments")
    exit 2
  elsif args.count < mandatory.length
    (args.count..(mandatory.length - 1)).to_a.each do |ix|
      MrMurano::Verbose.error(mandatory[ix])
    end
    exit 2
  end
end