lib/friends/commands/list.rb in friends-0.34 vs lib/friends/commands/list.rb in friends-0.35

- old
+ new

@@ -26,54 +26,57 @@ verbose: options[:verbose] ) end end - list.desc "Lists all activities" - list.command :activities do |list_activities| - list_activities.flag [:limit], - arg_name: "NUMBER", - desc: "The number of activities to return", - default_value: 10, - type: Integer + [:activities, :notes].each do |events| + list.desc "Lists all #{events}" + list.command events do |list_events| + list_events.flag [:limit], + arg_name: "NUMBER", + desc: "The number of #{events} to return", + default_value: 10, + type: Integer - list_activities.flag [:with], - arg_name: "NAME", - desc: "List only activities with the given friend", - type: Stripped, - multiple: true + list_events.flag [:with], + arg_name: "NAME", + desc: "List only #{events} with the given friend", + type: Stripped, + multiple: true - list_activities.flag [:in], - arg_name: "LOCATION", - desc: "List only activities in the given location", - type: Stripped + list_events.flag [:in], + arg_name: "LOCATION", + desc: "List only #{events} in the given location", + type: Stripped - list_activities.flag [:tagged], - arg_name: "@TAG", - desc: "List only activities with the given tag", - type: Tag, - multiple: true + list_events.flag [:tagged], + arg_name: "@TAG", + desc: "List only #{events} with the given tag", + type: Tag, + multiple: true - list_activities.flag [:since], - arg_name: "DATE", - desc: "List only activities on or after the given date", - type: InputDate + list_events.flag [:since], + arg_name: "DATE", + desc: "List only #{events} on or after the given date", + type: InputDate - list_activities.flag [:until], - arg_name: "DATE", - desc: "List only activities before or on the given date", - type: InputDate + list_events.flag [:until], + arg_name: "DATE", + desc: "List only #{events} before or on the given date", + type: InputDate - list_activities.action do |_, options| - puts @introvert.list_activities( - limit: options[:limit], - with: options[:with], - location_name: options[:in], - tagged: options[:tagged], - since_date: options[:since], - until_date: options[:until] - ) + list_events.action do |_, options| + puts @introvert.send( + "list_#{events}", + limit: options[:limit], + with: options[:with], + location_name: options[:in], + tagged: options[:tagged], + since_date: options[:since], + until_date: options[:until] + ) + end end end list.desc "List all locations" list.command :locations do |list_locations| @@ -83,12 +86,13 @@ end list.desc "List all tags used" list.command :tags do |list_tags| list_tags.flag [:from], - arg_name: '"activities" or "friends" (default: both)', - desc: "List only tags from activities or friends instead of"\ - "both" + arg_name: '"activities" or "friends" or "notes" (default: all)', + desc: "List only tags from activities, friends, or notes instead of"\ + "all three", + multiple: true list_tags.action do |_, options| puts @introvert.list_tags(from: options[:from]) end end