lib/ayadn/app.rb in ayadn-2.1 vs lib/ayadn/app.rb in ayadn-3.0

- old
+ new

@@ -2,11 +2,11 @@ module Ayadn class App < Thor package_name "Ayadn" begin - %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}" } + %w{action api descriptions endpoints cnx view workers settings post status extend databases fileops logs set alias errors blacklist mark nicerank debug check diagnostics}.each { |r| require_relative "#{r}" } rescue Interrupt puts "\nExit: stopped by user while launching\n\n" exit end @@ -252,10 +252,11 @@ 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) + require_relative("search") Action.new.hashtag(hashtag, options) end desc "search WORD(S)", "Show recents posts containing WORD(S) (-s)" map "-s" => :search @@ -269,10 +270,11 @@ 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.' option :annotations, type: :boolean, desc: 'Search for posts containing a specific App.net annotation.' def search(*words) + require_relative("search") Action.new.search(words.join(","), options) end desc "settings", "List current Ayadn settings (-sg)" map "-sg" => :settings @@ -302,10 +304,11 @@ option :blog, type: :boolean, desc: "Update your blog url" option :web, type: :boolean, desc: "Update your web url" option :avatar, type: :array, desc: "Update your avatar picture" option :cover, type: :array, desc: "Update your cover picture" def userupdate + require_relative("profile") Action.new.userupdate(options) end desc "postinfo POST", "Show detailed informations about a post (-pi)" map "-pi" => :postinfo @@ -453,10 +456,11 @@ 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) + require_relative("pinboard") Action.new.pin(post_id, tags, options) end desc "post Your text", "Simple post to App.net (-P)" map "-P" => :post @@ -564,10 +568,11 @@ option :deezer, aliases: "-d", type: :boolean, desc: "Get current track from Deezer 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 + require_relative("nowplaying") Action.new.nowplaying(options) end desc "movie TITLE", "Create a post from a movie title (-NW)" map "nowwatching" => :movie @@ -575,20 +580,22 @@ 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) + require_relative("nowwatching") 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) + require_relative("tvshow") Action.new.tvshow(title, options) end desc "random", "Show random posts from App.net (-rnd)" map "-rnd" => :random @@ -600,48 +607,53 @@ end desc "authorize", "Authorize Ayadn (-AU)" map "-auth" => :authorize map "-AU" => :authorize + option :api, aliases: "-a", type: :array, desc: "Provide an alternative root URL for the API call." + option :token, aliases: "-t", type: :array, desc: "Provide the token directly (bypass the webpage)" long_desc Descriptions.authorize - def authorize - Authorize.new.authorize + def authorize() + require_relative("authorize") + require_relative("switch") + Authorize.new.authorize(options) 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) + require_relative("authorize") + require_relative("switch") 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) + require_relative("switch") unless options[:list] Switch.new.switch(username) else Switch.new.list end end desc "version", "Show the current Ayadn version (-v)" map "-v" => :version def version - Action.new.version + Status.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 + desc "diagnostics", "Run diagnostics (-dg)" + map "-dg" => :diagnostics + map "check" => :diagnostics + map "test" => :diagnostics + subcommand "diagnostics", Diagnostics end end