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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/udb/cli.rb', line 74 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
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 151 |
# File 'lib/udb/cli.rb', line 115 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 extension: #{param.exts.map { |e| " - #{e.name}" }.join("\n")} Description: #{param.desc.gsub("\n", "\n ")} Value: #{param.schema.to_pretty_s} INFO end end |