Class: EasyCreds::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_creds/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, default_env: nil) ⇒ CLI

Returns a new instance of CLI.



18
19
20
21
22
23
24
# File 'lib/easy_creds/cli.rb', line 18

def initialize(root:, default_env: nil)
  @root        = Pathname.new(root)
  @default_env = default_env
  @config      = ConfigLoader.load(@root)
  @io          = CredentialsIO.new(@root)
  @prompt      = TTY::Prompt.new(interrupt: :exit, symbols: { selector: '' })
end

Class Method Details

.start(project: nil, default_env: nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/easy_creds/cli.rb', line 10

def self.start(project: nil, default_env: nil)
  root = project&.root || detect_root
  new(root: root, default_env: default_env).run
rescue Interrupt
  puts "\n\n  #{Theme.dim('Bye!')}\n"
  exit 0
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/easy_creds/cli.rb', line 26

def run
  check_op_cli!

  envs = EnvPicker.available(@root)
  abort 'No environments found in config/environments/.' if envs.empty?

  provider = build_op_client
  env      = pick_env(envs, provider)
  main_loop(env, provider, envs)
end