Class: Luciq::Commands::Auth
- Inherits:
-
Object
- Object
- Luciq::Commands::Auth
- Defined in:
- lib/luciq/commands/auth.rb
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(options = {}) ⇒ Auth
constructor
A new instance of Auth.
- #login ⇒ Object
- #logout ⇒ Object
- #whoami ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Auth
Returns a new instance of Auth.
9 10 11 |
# File 'lib/luciq/commands/auth.rb', line 9 def initialize( = {}) @options = end |
Instance Method Details
#info ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/luciq/commands/auth.rb', line 62 def info puts "Luciq CLI version: #{Luciq::VERSION}" puts '=' * 40 puts puts 'Configuration:' puts " URL: #{Config.load_base_url}" puts " Authentication Token: #{Config.load_token || '(not set)'}" end |
#login ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/luciq/commands/auth.rb', line 13 def login token = @options[:auth_token] unless token puts 'Login to Luciq' puts '=' * 40 puts 'Generate a CLI token from your Luciq dashboard: https://dashboard.luciq.ai/company/cli' puts puts "Note: For self-hosted clusters, replace 'dashboard' with your cluster name." puts print 'Paste your CLI token: ' token = $stdin.gets.chomp puts end if token.empty? puts '✗ No token provided.' exit 1 end Config.save_token(token) puts '✓ Token saved to ~/.luciqrc' puts "Run 'luciq info' to verify your configuration." end |
#logout ⇒ Object
57 58 59 60 |
# File 'lib/luciq/commands/auth.rb', line 57 def logout Config.clear_token puts '✓ Logged out.' end |
#whoami ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/luciq/commands/auth.rb', line 39 def whoami client = API::Client.new unless Config.load_token puts '✗ Not authenticated. Run: luciq login' exit 1 end response = client.whoami puts 'Authenticated as:' puts " Email: #{response['email']}" puts " Name: #{response['name']}" rescue StandardError => e puts "✗ #{e.}" exit 1 end |