Skip to content

Commit c1bb236

Browse files
authored
feat: add output option to udb list extensions (#1137)
Adds an option to choose the output file for `./bin/udb list extensions`. The default is still stdout. This mirrors the option that already exists for `./bin/udb list parameters`.
1 parent 13ae618 commit c1bb236

File tree

1 file changed

+9
-1
lines changed
  • tools/ruby-gems/udb/lib/udb

1 file changed

+9
-1
lines changed

tools/ruby-gems/udb/lib/udb/cli.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,17 @@ class List < SubCommandBase
158158
method_option :gen, type: :string, desc: "Path to folder used for generation", default: Udb.default_gen_path.to_s
159159
method_option :config, type: :string, required: true, desc: "Configuration name, or path to a config file", default: "_"
160160
method_option :config_dir, type: :string, desc: "Path to directory with config files", default: Udb.default_cfgs_path.to_s
161+
method_option :output, aliases: "-o", type: :string, desc: "Output file, or '-' for stdout", default: "-"
161162
def extensions
162163
raise ArgumentError, "Arch directory does not exist: #{options[:arch]}" unless File.directory?(options[:arch])
163164

165+
out =
166+
if options[:output] == "-"
167+
$stdout
168+
else
169+
File.open(options[:output], "w")
170+
end
171+
164172
cfg_file =
165173
if File.file?(options[:config])
166174
Pathname.new(options[:config])
@@ -178,7 +186,7 @@ def extensions
178186
)
179187
cfg_arch = resolver.cfg_arch_for(cfg_file.realpath)
180188
cfg_arch.possible_extensions.each do |ext|
181-
puts ext.name
189+
out.puts ext.name
182190
end
183191
end
184192

0 commit comments

Comments
 (0)