Sha256: 74012dcd2477b77fb8c1d33966dbc89172fcb25511310185de2dbea82c8f5a97

Contents?: true

Size: 846 Bytes

Versions: 10

Compression:

Stored size: 846 Bytes

Contents

module Twurl
  class AliasesController < AbstractCommandController
    NO_ALIASES_MESSAGE       = "No aliases exist. Set one this way: twurl alias h /1.1/statuses/home_timeline.json"
    NO_PATH_PROVIDED_MESSAGE = "No path was provided to alias. Paths must start with a forward slash (ex. /1.1/statuses/update.json)."
    def dispatch
      case options.subcommands.size
      when 0
        aliases = OAuthClient.rcfile.aliases
        if aliases && !aliases.empty?
          aliases.keys.sort.each do |name|
            CLI.puts "#{name}: #{aliases[name]}"
          end
        else
          CLI.puts NO_ALIASES_MESSAGE
        end
      when 1
        if options.path
          OAuthClient.rcfile.alias(options.subcommands.first, options.path)
        else
          CLI.puts NO_PATH_PROVIDED_MESSAGE
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
twurl-0.9.6 lib/twurl/aliases_controller.rb
twurl-0.9.5 lib/twurl/aliases_controller.rb
twurl-0.9.4 lib/twurl/aliases_controller.rb
twurl-0.9.3 lib/twurl/aliases_controller.rb
twurl-0.9.2 lib/twurl/aliases_controller.rb
twurl-0.9.1 lib/twurl/aliases_controller.rb
twurl-0.9.0 lib/twurl/aliases_controller.rb
twurl-0.8.3 lib/twurl/aliases_controller.rb
twurl-0.8.2 lib/twurl/aliases_controller.rb
twurl-0.8.1 lib/twurl/aliases_controller.rb