Skip to content

Commit 46afe5e

Browse files
author
Kevin Paulisse
committed
Add mutual exclusivity of --hiera-path and --hiera-path-strip
1 parent 4e28776 commit 46afe5e

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

lib/octocatalog-diff/catalog-diff/cli/options/hiera_path.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
def parse(parser, options)
99
parser.on('--hiera-path PATH', 'Path to hiera data directory, relative to top directory of repository') do |path_in|
10+
raise ArgumentError, '--hiera-path and --hiera-path-strip are mutually exclusive' if options.key?(:hiera_path_strip)
11+
1012
options[:hiera_path] = path_in
1113

1214
if options[:hiera_path].start_with?('/')

lib/octocatalog-diff/catalog-diff/cli/options/hiera_path_strip.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
def parse(parser, options)
88
parser.on('--hiera-path-strip PATH', 'Path prefix to strip when munging hiera.yaml') do |path_in|
9+
raise ArgumentError, '--hiera-path and --hiera-path-strip are mutually exclusive' if options.key?(:hiera_path)
10+
911
options[:hiera_path_strip] = path_in
1012
end
1113
end

spec/octocatalog-diff/tests/catalog-diff/cli/options/hiera_path_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@
1919
it 'should error if empty' do
2020
expect { run_optparse(['--hiera-path', '']) }.to raise_error(ArgumentError, /must not be empty/)
2121
end
22+
23+
it 'should error if --hiera-path and --hiera-path-strip are both specified' do
24+
expect do
25+
run_optparse(['--hiera-path', 'foo', '--hiera-path-strip', 'bar'])
26+
end.to raise_error(ArgumentError, /mutually exclusive/)
27+
end
2228
end
2329
end

0 commit comments

Comments
 (0)