Class: SchwarmCli::Commands::Configure
- Defined in:
- lib/schwarm_cli/commands/configure.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
exit_on_failure?, pagination_options
Instance Method Details
#setup ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/schwarm_cli/commands/configure.rb', line 11 def setup url = Gum.input(header: "Schwarm Server URL", value: "https://schwarm.getdexter.net") abort "Cancelled." unless url api_key = Gum.input(header: "API Key", password: true, placeholder: "sk-schwarm-...") abort "Cancelled." unless api_key config = SchwarmCli::Config.new(url:, api_key:) client = SchwarmCli::Client.new(url:, api_key:) Gum.spin("Testing connection...") { client.repositories.list(per_page: 1) } config.save puts "Configuration saved to #{config.config_path}" rescue Faraday::UnauthorizedError abort "Error: Invalid API key." rescue Faraday::Error => e abort "Error: Could not connect to server (#{e.})." end |