Class: GridCLI::SubgridCommand

Inherits:
BaseCommand show all
Defined in:
lib/gridcli/commands/subgrid.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#cmd, #desc

Instance Method Summary collapse

Methods inherited from BaseCommand

#add_format_option, #add_option, #error, #log, #output_format, #parse_dates, #parse_opts, #pop_arg, #pprint

Constructor Details

#initializeSubgridCommand

Returns a new instance of SubgridCommand.



3
4
5
# File 'lib/gridcli/commands/subgrid.rb', line 3

def initialize
  super "subgrid", "Create / read / update subgrids (groups)"
end

Instance Method Details

#run(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gridcli/commands/subgrid.rb', line 11

def run(args)
  subgrids = SubGrids.new

  groups = (args.length == 0) ? subgrids.groups : [args.shift]

  # if setting users...
  if args.length > 0
    subgrids.set_group(groups.first, args.first.split(","))
  end

  groups.each { |gname|
    error("Group not found: #{gname}") unless subgrids.groups.include? gname
    puts "#{gname} has users: #{subgrids.get_group(gname).join(', ')}"
  }

end

#usageObject



7
8
9
# File 'lib/gridcli/commands/subgrid.rb', line 7

def usage
  super "[<groupname> [<comma separated list of users>]]"
end