Class: ShopifyCli::Form
- Inherits:
-
Object
- Object
- ShopifyCli::Form
- Defined in:
- lib/shopify-cli/form.rb
Direct Known Subclasses
Extension::Forms::Create, Extension::Forms::Register, Node::Forms::Create, Rails::Forms::Create, Script::Forms::Create
Instance Attribute Summary collapse
-
#ctx ⇒ Object
Returns the value of attribute ctx.
-
#xargs ⇒ Object
Returns the value of attribute xargs.
Class Method Summary collapse
- .ask(ctx, args, flags) ⇒ Object
- .flag_arguments(*args) ⇒ Object
- .positional_arguments(*args) ⇒ Object
Instance Method Summary collapse
-
#initialize(ctx, xargs, attributes) ⇒ Form
constructor
A new instance of Form.
Constructor Details
#initialize(ctx, xargs, attributes) ⇒ Form
Returns a new instance of Form.
34 35 36 37 38 |
# File 'lib/shopify-cli/form.rb', line 34 def initialize(ctx, xargs, attributes) @ctx = ctx @xargs = xargs attributes.each { |k, v| send("#{k}=", v) unless v.nil? } end |
Instance Attribute Details
#ctx ⇒ Object
Returns the value of attribute ctx.
32 33 34 |
# File 'lib/shopify-cli/form.rb', line 32 def ctx @ctx end |
#xargs ⇒ Object
Returns the value of attribute xargs.
32 33 34 |
# File 'lib/shopify-cli/form.rb', line 32 def xargs @xargs end |
Class Method Details
.ask(ctx, args, flags) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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.) nil end end |
.flag_arguments(*args) ⇒ Object
26 27 28 29 |
# File 'lib/shopify-cli/form.rb', line 26 def flag_arguments(*args) @flag_arguments = args attr_accessor(*args) end |
.positional_arguments(*args) ⇒ Object
21 22 23 24 |
# File 'lib/shopify-cli/form.rb', line 21 def positional_arguments(*args) @positional_arguments = args attr_accessor(*args) end |