Class: Udb::CliCommands::Show
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Udb::CliCommands::Show
- Includes:
- Thor::Actions
- Defined in:
- lib/udb/cli.rb
Instance Method Summary collapse
Instance Method Details
#extension(ext_name) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/udb/cli.rb', line 131 def extension(ext_name) raise ArgumentError, "Arch directory does not exist: #{[:arch]}" unless File.directory?([:arch]) cfg_file = if File.file?([:config]) Pathname.new([:config]) elsif File.file?("#{[:config_dir]}/#{[:config]}.yaml") Pathname.new("#{[:config_dir]}/#{[:config]}.yaml") else raise ArgumentError, "Cannot find config: #{[:config]}" end resolver = Udb::Resolver.new( std_path_override: Pathname.new([:arch]), gen_path_override: Pathname.new([:gen]), custom_path_override: Pathname.new([:arch_overlay]) ) cfg_arch = resolver.cfg_arch_for(cfg_file.realpath) ext = cfg_arch.extension(ext_name) if ext.nil? say "Could not find an extension named '#{ext_name}'", :red else say <<~INFO #{ext.name} Extension #{ext.long_name} Versions: #{ext.versions.map { |ext_ver| " * #{ext_ver.version_str}" }.join("\n") } INFO say "Includes #{ext.instructions.count} instructions" if ext.instructions.count.positive? end end |
#parameter(param_name) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/udb/cli.rb', line 172 def parameter(param_name) raise ArgumentError, "Arch directory does not exist: #{[:arch]}" unless File.directory?([:arch]) cfg_file = if File.file?([:config]) Pathname.new([:config]) elsif File.file?("#{[:config_dir]}/#{[:config]}.yaml") Pathname.new("#{[:config_dir]}/#{[:config]}.yaml") else raise ArgumentError, "Cannot find config: #{[:config]}" end resolver = Udb::Resolver.new( std_path_override: Pathname.new([:arch]), gen_path_override: Pathname.new([:gen]), custom_path_override: Pathname.new([:arch_overlay]) ) cfg_arch = resolver.cfg_arch_for(cfg_file.realpath) param = cfg_arch.param(param_name) if param.nil? say "Could not find parameter named #{param_name}" else say <<~INFO #{param_name} Defined by: #{param.defined_by_condition.to_s_pretty} Description: #{param.description.gsub("\n", "\n ")} Value: #{param.schema.to_pretty_s} INFO end end |