Class: ShopifyCLI::Form
- Inherits:
-
Object
- Object
- ShopifyCLI::Form
- Defined in:
- lib/shopify_cli/form.rb
Direct Known Subclasses
Extension::Forms::Connect, Extension::Forms::Create, Node::Forms::Create, PHP::Forms::Create, Rails::Forms::Create, Theme::Syncer::Uploader::Forms::ApplyToAllForm, Theme::Syncer::Uploader::Forms::BaseStrategyForm, Theme::Forms::ConfirmStore, Theme::Forms::Select
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.
36 37 38 39 40 |
# File 'lib/shopify_cli/form.rb', line 36 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.
34 35 36 |
# File 'lib/shopify_cli/form.rb', line 34 def ctx @ctx end |
#xargs ⇒ Object
Returns the value of attribute xargs.
34 35 36 |
# File 'lib/shopify_cli/form.rb', line 34 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 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.) nil rescue ShopifyCLI::AbortSilent nil end end |
.flag_arguments(*args) ⇒ Object
28 29 30 31 |
# File 'lib/shopify_cli/form.rb', line 28 def flag_arguments(*args) @flag_arguments = args attr_accessor(*args) end |
.positional_arguments(*args) ⇒ Object
23 24 25 26 |
# File 'lib/shopify_cli/form.rb', line 23 def positional_arguments(*args) @positional_arguments = args attr_accessor(*args) end |