Class: Ace::Bundle::CLI::Commands::Load
- Inherits:
-
Support::Cli::Command
- Object
- Support::Cli::Command
- Ace::Bundle::CLI::Commands::Load
- Includes:
- Support::Cli::Base
- Defined in:
- lib/ace/bundle/cli/commands/load.rb
Overview
ace-support-cli Command class for the load command
Loads context from preset, file, or protocol URL
Instance Method Summary collapse
Instance Method Details
#call(input: nil, **options) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ace/bundle/cli/commands/load.rb', line 90 def call(input: nil, **) # Handle --help/-h passed as input argument if input == "--help" || input == "-h" # ace-support-cli will handle this return end if [:version] puts "ace-bundle #{Ace::Bundle::VERSION}" return end if [:list_presets] presets = Ace::Bundle.list_presets Atoms::PresetListFormatter.format(presets).each { |line| puts line } return end # Type-convert numeric options using Base helper for proper validation # coerce_types uses Integer() which raises ArgumentError on invalid input # (unlike .to_i which silently returns 0) coerce_types(, max_size: :integer, timeout: :integer) # Handle repeatable options (type: :array returns array, single values need wrapping) # --preset returns array when used multiple times, nil otherwise if [:preset] && [:presets] # If both --preset and --presets provided, merge them presets = [[:preset]].flatten + [:presets].split(",") [:preset] = presets.map(&:strip) elsif [:presets] [:preset] = [:presets].split(",").map(&:strip) elsif [:preset] # Ensure array even for single value [:preset] = [[:preset]].flatten end # Same for file option [:file] = [[:file]].flatten if [:file] # Normalize --compressor toggle if .key?(:compressor) && [:compressor] val = [:compressor].to_s.downcase [:compressor] = case val when "true", "yes", "on", "1" then "on" when "false", "no", "off", "0" then "off" else val end end # Normalize compressor_source_scope option if .key?(:compressor_source_scope) && [:compressor_source_scope] val = [:compressor_source_scope].to_s.downcase [:compressor_source_scope] = case val when "true", "yes", "on", "" then "per-source" when "false", "no", "off" then "off" else val end end execute(input, ) end |