Sha256: b4c1556943cb22d685742c312ebd5cfadb7e461006f0e67218396b1bfcbad817

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

Contents

require "highline/import"
require "netrc"
require "acquia_toolbelt/cli"

module AcquiaToolbelt
  class CLI
    class Auth < AcquiaToolbelt::Thor
      desc "login", "Login to your Acquia account."
      # Public: Login to an Acquia account.
      #
      # Save the login details in a netrc file for use for all authenticated
      # requests.
      #
      # Returns a status message.
      def login
        cli = HighLine.new
        user = cli.ask("Enter your username: ")
        password = cli.ask("Enter your password: ") { |q| q.echo = false }

        # Update (or create if needed) the netrc file that will contain the user
        # authentication details.
        n = Netrc.read
        n.new_item_prefix = "# This entry was added for connecting to the Acquia Cloud API\n"
        n["cloudapi.acquia.com"] = user, password
        n.save

        ui.success "Your user credentials have been successfully set."
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acquia_toolbelt-2.0.1 lib/acquia_toolbelt/cli/auth.rb
acquia_toolbelt-2.0.0 lib/acquia_toolbelt/cli/auth.rb