Sha256: 23799a8a1299da309de9226fb31dcda3db274298418ea2ce1a1c07029f5802e6

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'travis/cli'

module Travis
  module CLI
    class Endpoint < ApiCommand
      description 'displays or changes the API endpoint'

      skip :authenticate
      on '--drop-default', 'delete stored default endpoint'
      on '--set-default', 'store endpoint as global default'
      on '--github', 'display github endpoint'

      def run_github
        error '--github cannot be combined with --drop-default' if drop_default?
        error '--github cannot be combined with --set-default' if set_default?
        load_gh
        say github_endpoint.to_s, 'GitHub endpoint: %s'
      end

      def run_travis
        if drop_default? && (was = config['default_endpoint'])
          config.delete('default_endpoint')
          say was, 'default API endpoint dropped (was %s)'
        else
          config['default_endpoint'] = api_endpoint if set_default?
          say api_endpoint, "API endpoint: %s#{' (stored as default)' if set_default?}"
        end
      end

      def run
        github? ? run_github : run_travis
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
travis-1.14.0 lib/travis/cli/endpoint.rb
travis-1.13.3 lib/travis/cli/endpoint.rb
travis-1.13.2 lib/travis/cli/endpoint.rb
travis-1.13.1 lib/travis/cli/endpoint.rb
travis-1.13.0 lib/travis/cli/endpoint.rb
travis-1.12.0 lib/travis/cli/endpoint.rb