Sha256: 6d530f3a114441e6fb51b5d61b6f1874b322c4b242f61af8a23b848edb8b5b5f

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

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

module AcquiaToolbelt
  class CLI
    class Auth < AcquiaToolbelt::Thor
      # Public: Login to an Acquia account.
      #
      # Save the login details in a netrc file for use for all authenticated
      # requests.
      #
      # Returns a status message.
      desc "login", "Login to your Acquia account."
      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

1 entries across 1 versions & 1 rubygems

Version Path
acquia_toolbelt-2.3.1 lib/acquia_toolbelt/cli/auth.rb