Module: EasyCreds::Actions::Local::SyncKey

Defined in:
lib/easy_creds/actions/local/sync_key.rb

Class Method Summary collapse

Class Method Details

.call(ctx) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/easy_creds/actions/local/sync_key.rb', line 9

def self.call(ctx)
  Theme.section("Local overlay — sync key #{ctx.env}_local")

  direction = ctx.prompt.select(
    'Sync direction:',
    [
      { name: "push  — upload #{ctx.env}_local.key to 1Password", value: :push },
      { name: 'pull  — download key from 1Password', value: :pull },
      { name: 'cancel', value: :cancel }
    ],
    cycle: false
  )

  return if direction == :cancel

  local_field = "#{ctx.env}_local"
  direction == :push ? push_key(ctx, local_field) : pull_key(ctx, local_field)
end