Class: GridCLI::ListCommand
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
3
4
5
6
|
# File 'lib/gridcli/commands/list.rb', line 3
def initialize
super "list", "List posts of a particular kind or all posts"
add_format_option
end
|
Instance Method Details
#run(args) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/gridcli/commands/list.rb', line 12
def run(args)
type = (args.length > 0) ? args.shift : "all"
usage if not [ 'like', 'dislike', 'status', 'message', 'all' ].include? type
period = (args.length > 0 and not args.first.start_with? '-') ? args.shift : nil
dates = parse_dates period
parse_opts args
log "Showing #{type} posts in range #{dates.first || 'first'} - #{dates.last || 'last'}"
GridCLI.storage.list(type, dates[0], dates[1], output_format)
end
|
#usage ⇒ Object
8
9
10
|
# File 'lib/gridcli/commands/list.rb', line 8
def usage
super "<like|dislike|message|status|all> [<since time>][ to <end time>]"
end
|