lib/lionel/cli.rb in lionel_richie-0.1.4 vs lib/lionel/cli.rb in lionel_richie-0.1.5
- old
+ new
@@ -1,8 +1,7 @@
module Lionel
class CLI < Thor
-
desc "authorize PROVIDER", "Allows application to request user authorization for provider (google|trello)"
method_option "new-client", :aliases => "-n", :type => :boolean,
:default => false, :desc => "Set new google client credentials."
def authorize(provider)
case provider
@@ -41,12 +40,13 @@
desc "export", "Saves Trello export to Google Docs"
method_option "print", :aliases => "-p", :type => :boolean, :default => false, :desc => "Print results instead of saving them to Google Docs."
method_option "trello-board-id", :aliases => "-t", :type => :string, :default => nil, :desc => "Specify the source Trello board id."
method_option "google-doc-id", :aliases => "-g", :type => :string, :default => nil, :desc => "Specify the target Google doc id."
method_option "save", :aliases => "-c", :type => :string, :default => true, :desc => "Save the command line ids as the default configuration."
+ method_option "filter", :aliases => "-f", :type => :string, :default => 'open-lists', :desc => "Possible values: open-cards, open-lists."
def export
- export = Lionel::Export.new
+ export = Lionel::Export.new(options)
if options['google-doc-id']
export.google_doc_id = options['google-doc-id']
elsif !export.google_doc_id
export.google_doc_id = ask("Enter a google doc id to export to:")
@@ -58,22 +58,29 @@
export.trello_board_id = ask("Enter a trello board id to export from:")
end
export.save_configuration if options['save']
- export.authenticate
+ begin
+ export.authenticate
+ rescue GoogleDrive::Error, GoogleDrive::AuthenticationError
+ @google_attempts ||= 0
+ @google_attempts += 1
+ Lionel::GoogleAuthentication.new.refresh
+ if @google_attempts < 2
+ retry
+ else
+ invoke :authorize, ['google']
+ end
+ rescue Trello::Error, Trello::InvalidAccessToken
+ invoke :authorize, ['trello']
+ end
welcome = "Trello? Is it me you're looking for?"
say welcome
say '=' * welcome.size
- export.download
-
- if options['print']
- export.rows.each { |row| say row }
- else
- export.upload
- end
+ export.process
end
end
end