Class: Logi::CLI
- Inherits:
-
Thor
- Object
- Thor
- Logi::CLI
- Defined in:
- lib/logi/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #login ⇒ Object
- #logout ⇒ Object
- #manual ⇒ Object
- #version ⇒ Object
- #welcome ⇒ Object
- #whoami ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
123 124 125 |
# File 'lib/logi/cli.rb', line 123 def self.exit_on_failure? true end |
Instance Method Details
#login ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/logi/cli.rb', line 56 def login api_url = [:api_url] || ENV["LOGI_API_URL"] || Config::DEFAULT_API_URL portal_url = [:portal_url] || ENV["LOGI_PORTAL_URL"] if [:loopback] # Same-device loopback redirect (PKCE). No code to type; auto-completes # via 127.0.0.1 callback. Supports custom --scope. Commands::Login.perform( api_url: api_url, portal_url: portal_url, name: [:name], scopes: [:scope] ) else # Default: device flow. Opens the browser with the code pre-filled AND # prints the code, so the user can approve here or on another device. # `--code` skips the browser for headless / SSH environments. Commands::DeviceLogin.perform( api_url: api_url, portal_url: portal_url, name: [:name], scopes: [:scope], open_browser: ![:code] ) end end |
#logout ⇒ Object
98 99 100 101 |
# File 'lib/logi/cli.rb', line 98 def logout Config.clear puts "✓ Signed out (credentials deleted)" end |
#manual ⇒ Object
119 120 121 |
# File 'lib/logi/cli.rb', line 119 def manual Commands::Manual.perform(full: [:full]) end |
#version ⇒ Object
45 46 47 |
# File 'lib/logi/cli.rb', line 45 def version puts "logi-cli #{Logi::VERSION}" end |
#welcome ⇒ Object
9 10 11 12 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 38 |
# File 'lib/logi/cli.rb', line 9 def welcome pastel = Pastel.new logged_in = Config.load.authenticated? puts pastel.bold("logi") + pastel.dim(" — Identity Provider CLI") puts "" if logged_in config = Config.load puts pastel.green("✓ Signed in") + pastel.dim(" — #{config.api_url}") puts "" puts pastel.bold("Common commands") puts " logi apps list # List your OAuth apps" puts " logi apps create --name \"My App\" -r URL # Register a new app" puts " logi apps verify <id> -r URL # Check an RP integration (env / redirect URI)" puts " logi apps rotate-secret <id> # Rotate client_secret" puts " logi whoami # Show sign-in info" puts " logi manual # Agent-oriented manual (paste into your AI agent)" puts " logi --help # All commands" else puts pastel.yellow("You're not signed in yet.") puts "" puts pastel.bold("Get started in 3 steps:") puts pastel.dim(" 1.") + " " + pastel.cyan("logi login") + pastel.dim(" # Sign in via your browser") puts pastel.dim(" 2.") + " " + pastel.cyan("logi apps create --name \"App name\" -r URL") + pastel.dim(" # Register your first app") puts pastel.dim(" 3.") + " " + pastel.cyan("logi apps list") + pastel.dim(" # Check your apps") puts "" puts pastel.dim("Docs: https://docs.1pass.dev") end end |
#whoami ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/logi/cli.rb', line 84 def whoami config = Config.load pastel = Pastel.new unless config.authenticated? abort pastel.red("You're not signed in. Run `logi login`.") end puts "API URL: #{config.api_url}" puts "Source: #{config.source}" puts "Name: #{config.name || '-'}" puts "PAK: #{config.api_key[0, 18]}…" end |