Class: OsCtl::Cli::Receive

Inherits:
Command
  • Object
show all
Defined in:
lib/osctl/cli/receive.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #gopts, #opts

Instance Method Summary collapse

Methods inherited from Command

#cli_opt, #format_output, #initialize, #osctld_call, #osctld_fmt, #osctld_open, #osctld_resp, #require_args!, run

Methods included from Utils::Humanize

#break_interval, #format_long_duration, #format_percent, #format_short_duration, #humanize_data, #humanize_time_ns, #parse_data

Constructor Details

This class inherits a constructor from OsCtl::Cli::Command

Instance Method Details

#authorized_keys_addObject



17
18
19
20
21
22
23
# File 'lib/osctl/cli/receive.rb', line 17

def authorized_keys_add
  osctld_fmt(
    :receive_authkey_add,
    pool: gopts[:pool],
    public_key: STDIN.readline.strip
  )
end

#authorized_keys_deleteObject



25
26
27
28
29
30
31
32
# File 'lib/osctl/cli/receive.rb', line 25

def authorized_keys_delete
  require_args!('index')
  osctld_fmt(
    :receive_authkey_delete,
    pool: gopts[:pool],
    index: args[0].to_i
  )
end

#authorized_keys_listObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/osctl/cli/receive.rb', line 5

def authorized_keys_list
  keys = osctld_call(:receive_authkey_list, pool: gopts[:pool])

  i = 0

  format_output(keys.map do |key|
    ret = {index: i, key: key}
    i += 1
    ret
  end)
end

#authorized_keys_setObject



34
35
36
37
38
39
40
# File 'lib/osctl/cli/receive.rb', line 34

def authorized_keys_set
  osctld_fmt(
    :receive_authkey_set,
    pool: gopts[:pool],
    public_keys: read_keys(STDIN),
  )
end

#read_keys(io) ⇒ Object (protected)



43
44
45
46
47
# File 'lib/osctl/cli/receive.rb', line 43

def read_keys(io)
  keys = []
  keys << io.readline.strip until io.eof?
  keys
end