lib/ayadn/app.rb in ayadn-1.8.2 vs lib/ayadn/app.rb in ayadn-2.0

- old
+ new

@@ -1,11 +1,11 @@ # encoding: utf-8 module Ayadn class App < Thor package_name "Ayadn" - %w{action stream api search descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark nicerank debug check nowplaying nowwatching tvshow annotations profile}.each { |r| require_relative "#{r}" } + %w{action stream api search descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark nicerank debug check nowplaying nowwatching tvshow annotations profile migration}.each { |r| require_relative "#{r}" } ## # These methods are intended to be called from the CLI. desc "timeline", "Show your App.net timeline, aka the Unified Stream (-tl)" @@ -16,10 +16,11 @@ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def timeline Action.new.unified(options) end desc "checkins", "Show the Checkins Stream (-ck)" @@ -29,10 +30,11 @@ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def checkins Action.new.checkins(options) end desc "global", "Show the Global Stream (-gl)" @@ -42,10 +44,11 @@ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def global Action.new.global(options) end desc "trending", "Show the Trending Stream (-tr)" @@ -55,10 +58,11 @@ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def trending Action.new.trending(options) end desc "photos", "Show the Photos Stream (-ph)" @@ -68,10 +72,11 @@ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def photos Action.new.photos(options) end desc "conversations", "Show the Conversations Stream (-cq)" @@ -81,10 +86,11 @@ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def conversations Action.new.conversations(options) end desc "mentions @USERNAME", "Show posts containing a mention of @username (-m)" @@ -93,10 +99,11 @@ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream" option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def mentions(*username) Action.new.mentions(username, options) end desc "userposts @USERNAME", "Show posts by @username (-up)" @@ -105,18 +112,20 @@ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream" option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def userposts(*username) Action.new.posts(username, options) end desc "interactions", "Show your recent ADN activity (-int)" map "-int" => :interactions long_desc Descriptions.interactions option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def interactions Action.new.interactions(options) end desc "whatstarred @USERNAME", "Show posts starred by @username (-was)" @@ -124,26 +133,31 @@ long_desc Descriptions.whatstarred option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :extract, aliases: "-e", type: :boolean, desc: Descriptions.options_extract + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def whatstarred(*username) Action.new.whatstarred(username, options) end desc "whoreposted POST", "List users who reposted a post (-wor)" map "-wor" => :whoreposted long_desc Descriptions.whoreposted option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :force, aliases: "-f", type: :boolean, desc: "Force retrieve the actual post id (ignores index)" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def whoreposted(post_id) Action.new.whoreposted(post_id, options) end desc "whostarred POST", "List users who starred a post (-wos)" map "-wos" => :whostarred long_desc Descriptions.whostarred option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :force, aliases: "-f", type: :boolean, desc: "Force retrieve the actual post id (ignores index)" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def whostarred(post_id) Action.new.whostarred(post_id, options) end desc "convo POST", "Show the conversation thread around a post (-co)" @@ -151,63 +165,90 @@ map "thread" => :convo option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream" option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" long_desc Descriptions.convo def convo(post_id) Action.new.convo(post_id, options) end desc "followings @USERNAME", "List users @username is following (-fwg)" map "-fwg" => :followings long_desc Descriptions.followings option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order" + option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username" + option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name" + option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day" + option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def followings(*username) Action.new.followings(username, options) end desc "followers @USERNAME", "List users following @username (-fwr)" map "-fwr" => :followers long_desc Descriptions.followers option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order" + option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username" + option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name" + option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day" + option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def followers(*username) Action.new.followers(username, options) end desc "muted", "List the users you muted (-mtd)" map "-mtd" => :muted long_desc Descriptions.muted option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order" + option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username" + option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name" + option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day" + option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def muted Action.new.muted(options) end desc "blocked", "List the users you blocked (-bkd)" map "-bkd" => :blocked long_desc Descriptions.blocked option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order" + option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username" + option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name" + option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day" + option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def blocked Action.new.blocked(options) end desc "hashtag HASHTAG", "Show recent posts containing #HASHTAG (-t)" map "-t" => :hashtag long_desc Descriptions.hashtag option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :extract, aliases: "-e", type: :boolean, desc: Descriptions.options_extract option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def hashtag(hashtag) Action.new.hashtag(hashtag, options) end desc "search WORD(S)", "Show recents posts containing WORD(S) (-s)" map "-s" => :search long_desc Descriptions.search option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" option :extract, aliases: "-e", type: :boolean, desc: Descriptions.options_extract option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force option :messages, type: :boolean, desc: 'Search for WORD(S) in messages, including PMs.' option :users, type: :boolean, desc: 'Search for App.net users by searching WORD(S) in their bio/description.' option :channels, type: :boolean, desc: 'Search for App.net channels by searching WORD(S) in their description.' @@ -218,18 +259,20 @@ desc "settings", "List current Ayadn settings (-sg)" map "-sg" => :settings long_desc Descriptions.settings option :raw, aliases: "-x", type: :boolean, desc: "Outputs the raw list in JSON" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def settings Action.new.view_settings(options) end desc "userinfo @USERNAME", "Show detailed informations about @username (-ui)" map "-ui" => :userinfo long_desc Descriptions.userinfo option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def userinfo(*username) Action.new.userinfo(username, options) end desc "userupdate", "Update your user profile informations (-U)" @@ -250,10 +293,11 @@ desc "postinfo POST", "Show detailed informations about a post (-pi)" map "-pi" => :postinfo long_desc Descriptions.postinfo option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def postinfo(post_id) Action.new.postinfo(post_id, options) end desc "files", "List your files (-fl)" @@ -267,12 +311,13 @@ end desc "delete POST", "Delete a post (-D)" map "-D" => :delete long_desc Descriptions.delete + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force def delete(*post_id) - Action.new.delete(post_id) + Action.new.delete(post_id, options) end desc "delete_m CHANNEL MESSAGE", "Delete a message (-DM)" map "-DM" => :delete_m long_desc Descriptions.delete_m @@ -302,33 +347,37 @@ end desc "unrepost POST", "Unrepost a post (-UR)" map "-UR" => :unrepost long_desc Descriptions.unrepost - def unrepost(post_id) - Action.new.unrepost(post_id) + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + def unrepost(*post_id) + Action.new.unrepost(post_id, options) end desc "unstar POST", "Unstar a post (-US)" map "-US" => :unstar long_desc Descriptions.unstar - def unstar(post_id) - Action.new.unstar(post_id) + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + def unstar(*post_id) + Action.new.unstar(post_id, options) end desc "star POST", "Star a post (-ST)" map "-ST" => :star long_desc Descriptions.star - def star(post_id) - Action.new.star(post_id) + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + def star(*post_id) + Action.new.star(post_id, options) end desc "repost POST", "Repost a post (-O)" map "-O" => :repost long_desc Descriptions.repost - def repost(post_id) - Action.new.repost(post_id) + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + def repost(*post_id) + Action.new.repost(post_id, options) end desc "follow @USERNAME", "Follow @username (-FO)" map "-FO" => :follow long_desc Descriptions.follow @@ -352,10 +401,14 @@ desc "channels", "List your active channels (-ch)" map "-ch" => :channels long_desc Descriptions.channels option :id, aliases: "-i", type: :array, desc: "Retrieve only the specified channel(s)" + option :broadcasts, aliases: "-b", type: :boolean, desc: "Only your broadcast channel(s)" + option :messages, aliases: "-m", type: :boolean, desc: "Only your private messaging channel(s)" + option :patter, aliases: "-p", type: :boolean, desc: "Only your patter room channel(s)" + option :other, aliases: "-o", type: :boolean, desc: "Only other than private messaging and broadcasts channel(s)" option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw def channels Action.new.channels(options) end @@ -365,35 +418,39 @@ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream" option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new option :count, aliases: "-c", type: :numeric, desc: "Specify the number of messages to retrieve" option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channel as read" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" def messages(channel_id) Action.new.messages(channel_id, options) end desc "messages_unread", "Show your unread private messages (-pmu)" map "-pmu" => :messages_unread option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channels as read" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" long_desc Descriptions.messages_unread def messages_unread Action.new.messages_unread(options) end desc "pin POST TAG(S)", "Export a post's link and text with tags to Pinboard" long_desc Descriptions.pin + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force def pin(post_id, *tags) - Action.new.pin(post_id, tags) + Action.new.pin(post_id, tags, options) end desc "post Your text", "Simple post to App.net (-P)" map "-P" => :post long_desc Descriptions.post option :embed, aliases: "-E", type: :array, desc: "Embed one or several pictures in the new post" option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new post" option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new post" option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new post" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def post(*args) Action.new.post(args, options) end desc "write", "Multi-line post to App.net (-W)" @@ -402,10 +459,11 @@ long_desc Descriptions.write option :embed, aliases: "-E", type: :array, desc: "Embed one or several pictures in the new post" option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new post" option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new post" option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new post" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def write Action.new.write(options) end desc "pm @USERNAME", "Send a private message to @username" @@ -413,10 +471,11 @@ option :embed, aliases: "-E", type: :array, desc: "Embed one or several pictures in the new message" option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new message" option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new message" option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new message" option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channel as read" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def pm(*username) Action.new.pmess(username, options) end desc "send CHANNEL", "Send a message to a CHANNEL (-C)" @@ -425,10 +484,11 @@ option :embed, aliases: "-E", type: :array, desc: "Embed one or several pictures in the new message" option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new message" option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new message" option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new message" option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channel as read" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def send_to_channel(channel_id) Action.new.send_to_channel(channel_id, options) end desc "reply POST", "Reply to post nĀ°POST (-R)" @@ -437,10 +497,12 @@ option :embed, aliases: "-E", type: :array, desc: "Embed one or several pictures in the new post" option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new post" option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new post" option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new post" option :noredirect, aliases: "-n", type: :boolean, desc: "Do not respond to the original post but to the reposted one if possible" + option :force, aliases: "-f", type: :boolean, desc: Descriptions.options_force + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def reply(id) ayadn = Action.new ayadn.reply(id, options) end @@ -480,50 +542,67 @@ map "-np" => :nowplaying map "-NP" => :nowplaying long_desc Descriptions.nowplaying option :no_url, aliases: "-n", type: :boolean, desc: "Don't append preview or album art at the end of the post" option :lastfm, aliases: "-l", type: :boolean, desc: "Get current track from Last.fm instead of iTunes" + option :hashtag, aliases: "-h", type: :array, desc: "Specify a custom hashtag" + option :text, aliases: "-t", type: :array, desc: "Add custom text" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def nowplaying Action.new.nowplaying(options) end desc "movie TITLE", "Create a post from a movie title (-NW)" map "nowwatching" => :movie map "imdb" => :movie map "-NW" => :movie long_desc Descriptions.nowwatching option :alt, aliases: "-a", type: :boolean, desc: "Select an alternative response if the first didn't match" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def movie(*title) Action.new.nowwatching(title, options) end desc "tvshow TITLE", "Create a post from a TV show title (-TV)" map "-TV" => :tvshow long_desc Descriptions.tvshow option :alt, aliases: "-a", type: :boolean, desc: "Select an alternative response if the first didn't match" option :banner, aliases: "-b", type: :boolean, desc: "Inserts the show banner instead of the show poster" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already (after posting)" def tvshow(*title) Action.new.tvshow(title, options) end desc "random", "Show random posts from App.net (-rnd)" map "-rnd" => :random option :wait, aliases: "-w", type: :numeric, desc: "In seconds, time to wait before next page" + option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already" long_desc Descriptions.random_posts def random Action.new.random_posts(options) end - desc "authorize", "Authorize Ayadn (-auth)" + desc "authorize", "Authorize Ayadn (-AU)" map "-auth" => :authorize + map "-AU" => :authorize long_desc Descriptions.authorize def authorize Authorize.new.authorize end + desc "unauthorize @USERNAME", "Unauthorize an Ayadn user account (-UA)" + map "-unauth" => :unauthorize + map "-UA" => :unauthorize + option :delete, aliases: "-D", type: :boolean, desc: "Deletes user folders (default: false)" + long_desc Descriptions.unauthorize + def unauthorize(*user) + Authorize.new.unauthorize(user, options) + end + desc "switch @USERNAME", "Switch between authorized App.net accounts (-@)" map "-@" => :switch + map "login" => :switch option :list, aliases: "-l", type: :boolean, desc: "List authorized accounts" long_desc Descriptions.switch def switch(*username) unless options[:list] Switch.new.switch(username) @@ -534,9 +613,17 @@ desc "version", "Show the current Ayadn version (-v)" map "-v" => :version def version Action.new.version + end + + desc "migrate", "Migrate databases (upgrade accounts)", :hide => true + map "upgrade" => :migrate + long_desc Descriptions.migrate + def migrate + mig = Migration.new + mig.all end end end