Class: ThoriumCLI::Thorium

Inherits:
Thor
  • Object
show all
Includes:
ApacheCLI, ConfigCLI, GitCLI, Thor::Actions
Defined in:
lib/thorium/base.rb

Overview

Top level tasks for thorium Includes routines that do not require packaging of subcomands

Constant Summary collapse

SKIP =
''
ALIAS =
'th'
OS =
ENV['_system_type']

Instance Method Summary collapse

Instance Method Details

#pubkeyObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/thorium/base.rb', line 29

def pubkey
  path = '~/.ssh/id_rsa.pub'
  file = Dir.glob(File.expand_path(path)).first
  if file
    say "Use `thorium pubkeys` if you want to select a specific key.", :yellow
    copy_to_clipboard file
  else
    say "File `#{path}` has not been found.", :red
    generate_pubkey?
  end
end

#pubkeysObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/thorium/base.rb', line 42

def pubkeys
  public_keys = Dir.glob(File.expand_path('~/.ssh') + '/*.pub')
  if public_keys.any?
    puts '', 'Public keys found:'
    puts '------------------'
    print_keys public_keys
    ask_options = { limited_to: ('1'..public_keys.size.to_s).to_a, skip: SKIP }
    index = ask('Which key do you want in your clipboard?', :green, ask_options)
    copy_to_clipboard public_keys[index.to_i - 1] if index != ask_options[:skip]
  else
    say 'No public keys have been found.', :red
    generate_pubkey?
  end
end