Method: ShopifyCLI::Form.ask

Defined in:
lib/shopify_cli/form.rb

.ask(ctx, args, flags) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shopify_cli/form.rb', line 6

def ask(ctx, args, flags)
  attrs = {}
  (@positional_arguments || []).each { |name| attrs[name] = args.shift }
  return nil if attrs.any? { |_k, v| v.nil? }
  (@flag_arguments || []).each { |arg| attrs[arg] = flags[arg] }
  form = new(ctx, args, attrs)
  begin
    form.ask
    form
  rescue ShopifyCLI::Abort => err
    ctx.puts(err.message)
    nil
  rescue ShopifyCLI::AbortSilent
    nil
  end
end