Sha256: 173f46793d6827404a75991ecc45adfcbffec0f7d0e168cda2fbd8619619a5d7

Contents?: true

Size: 1.31 KB

Versions: 13

Compression:

Stored size: 1.31 KB

Contents

module HammerCLIForeman

  class Auth < HammerCLI::AbstractCommand

    class LoginCommand < HammerCLI::AbstractCommand
      command_name "login"
      desc _("Set credentials")

      def execute
        HammerCLIForeman.credentials.clear
        HammerCLI::Connection.drop_all
        HammerCLIForeman.credentials.username
        HammerCLIForeman.credentials.password
        HammerCLI::EX_OK
      end
    end

    class LogoutCommand < HammerCLI::AbstractCommand
      command_name "logout"
      desc _("Wipe your credentials")

      def execute
        #NOTE: we will change that to drop(:foreman) once dynamic bindings are implemented
        HammerCLIForeman.credentials.clear
        HammerCLI::Connection.drop_all
        print_message(_("Credentials deleted."))
        HammerCLI::EX_OK
      end
    end

    class InfoCommand < HammerCLI::AbstractCommand
      command_name "status"
      desc _("Information about current connections")

      def execute
        unless HammerCLIForeman.credentials.empty?
          print_message(_("You are logged in as '%s'") % HammerCLIForeman.credentials.username)
        else
          print_message(_("You are currently not logged in to any service.\nUse the service to set credentials."))
        end
        HammerCLI::EX_OK
      end
    end

    autoload_subcommands
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hammer_cli_foreman-0.8.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.7.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.6.2 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.6.1 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.6.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.5.1 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.5.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.4.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.3.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.2.0 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.1.4 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.1.3 lib/hammer_cli_foreman/auth.rb
hammer_cli_foreman-0.1.2 lib/hammer_cli_foreman/auth.rb