Skip to content

Commit 3f6165c

Browse files
authored
Merge pull request #329 from puppetlabs/CONT-228-remove_deprecated_flags
(CONT-228) Remove deprecated emit flags
2 parents a120e39 + 0b2ff7f commit 3f6165c

File tree

2 files changed

+9
-37
lines changed

2 files changed

+9
-37
lines changed

lib/puppet/face/strings.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
option '--markup FORMAT' do
1919
summary "The markup format to use for docstring text (defaults to 'markdown')."
2020
end
21-
option '--emit-json-stdout' do
22-
summary 'DEPRECATED: Print JSON representation of the documentation to stdout.'
23-
end
24-
option '--emit-json PATH' do
25-
summary 'DEPRECATED: Write JSON representation of the documentation to the given file.'
26-
end
2721

2822
summary 'Generate documentation from files.'
2923
arguments '[[search_pattern] ...]'
@@ -157,12 +151,6 @@ def build_generate_options(options = nil, *yard_args)
157151
generate_options[:backtrace] = Puppet[:trace]
158152
generate_options[:yard_args] = yard_args unless yard_args.empty?
159153
if options
160-
if options[:emit_json]
161-
warn "WARNING: '--emit-json PATH' is deprecated. Use '--format json --out PATH' instead."
162-
end
163-
if options[:emit_json_stdout]
164-
warn "WARNING: '--emit-json-stdout' is deprecated. Use '--format json' instead."
165-
end
166154
markup = options[:markup]
167155
generate_options[:markup] = markup if markup
168156
generate_options[:path] = options[:out] if options[:out]
@@ -178,15 +166,11 @@ def build_generate_options(options = nil, *yard_args)
178166
if format
179167
if format.casecmp('markdown').zero?
180168
generate_options[:markdown] = true
181-
elsif format.casecmp('json').zero? || options[:emit_json] || options[:emit_json_stdout]
169+
elsif format.casecmp('json').zero?
182170
generate_options[:json] = true
183-
generate_options[:path] ||= options[:emit_json] if options[:emit_json]
184171
else
185172
raise "Invalid format #{options[:format]}. Please select 'json' or 'markdown'."
186173
end
187-
elsif options[:emit_json] || options[:emit_json_stdout]
188-
generate_options[:json] = true
189-
generate_options[:path] ||= options[:emit_json] if options[:emit_json]
190174
end
191175
end
192176
generate_options

spec/acceptance/emit_json_options_spec.rb renamed to spec/acceptance/generate_json_spec.rb

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'Emitting JSON' do
5+
describe 'Generating JSON' do
66
let(:test_module_path) do
77
sut_module_path(%r{Module test})
88
end
@@ -50,26 +50,14 @@
5050
}
5151
end
5252

53-
[
54-
{ title: '--format json and STDOUT', cmd_line: '--format json' },
55-
{ title: '--emit-json-stdout', cmd_line: '--emit-json-stdout' },
56-
].each do |testcase|
57-
it "emits JSON to stdout when using #{testcase[:title]}" do
58-
output = run_shell("puppet strings generate #{testcase[:cmd_line]} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"").stdout.chomp
59-
expect(JSON.parse(output)).to eq(expected)
60-
end
53+
it 'renders JSON to stdout when using --format json' do
54+
output = run_shell("puppet strings generate --format json \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"").stdout.chomp
55+
expect(JSON.parse(output)).to eq(expected)
6156
end
6257

63-
[
64-
{ title: '--format json and --out', cmd_line: '--format json --out "TMPFILE"' },
65-
{ title: '--emit-json', cmd_line: '--emit-json "TMPFILE"' },
66-
].each do |testcase|
67-
it "writes JSON to a file when using #{testcase[:title]}" do
68-
tmpfile = File.join(remote_tmp_path, 'json_output.json')
69-
cmd = "puppet strings generate #{testcase[:cmd_line].gsub('TMPFILE', tmpfile)} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\""
70-
run_shell(cmd)
71-
output = JSON.parse(file(tmpfile).content)
72-
expect(output).to eq(expected)
73-
end
58+
it 'writes JSON to a file when using --format json --out' do
59+
tmpfile = File.join(remote_tmp_path, 'json_output.json')
60+
run_shell("puppet strings generate --format json --out #{tmpfile} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"")
61+
expect(JSON.parse(file(tmpfile).content)).to eq(expected)
7462
end
7563
end

0 commit comments

Comments
 (0)