Skip to content

Commit f1f4430

Browse files
author
Kevin Paulisse
committed
Add ENC override CLI option
1 parent 6efbe3f commit f1f4430

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
# Allow override of ENC parameters on the command line. ENC parameter overrides can be supplied for the 'to' or 'from' catalog,
4+
# or for both. There is some attempt to handle data types here (since all items on the command line are strings)
5+
# by permitting a data type specification as well. For parameters nested in hashes, use `::` as the delimiter.
6+
OctocatalogDiff::Cli::Options::Option.newoption(:enc_override) do
7+
has_weight 322
8+
9+
def parse(parser, options)
10+
# Set 'enc_override_in' because more processing is needed, once the command line options
11+
# have been parsed, to make this into the final form 'enc_override'.
12+
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
13+
parser: parser,
14+
options: options,
15+
cli_name: 'enc-override',
16+
option_name: 'enc_override_in',
17+
desc: 'Override parameter from ENC',
18+
datatype: []
19+
)
20+
end
21+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../options_helper'
4+
5+
describe OctocatalogDiff::Cli::Options do
6+
describe '#opt_enc_override' do
7+
include_examples 'global array option', 'enc-override', :enc_override_in
8+
9+
it 'should accept multiple ENC parameters of the same type' do
10+
args = ['--to-enc-override', 'foo=bar', '--to-enc-override', 'baz=buzz']
11+
result = run_optparse(args)
12+
expect(result[:to_enc_override_in]).to eq(['foo=bar', 'baz=buzz'])
13+
end
14+
end
15+
end

0 commit comments

Comments
 (0)