summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-10-30 01:00:17 -0600
committerDan Allen <dan.j.allen@gmail.com>2021-10-30 01:00:17 -0600
commitb8a6c8662cd0b5514af223b71cfdbb7c87e72f51 (patch)
tree45d0c45df6f4166ac209f2fc1d83855c4023d8b8
parenta227fcd0129e03e2478390a27dd02965a3146ab4 (diff)
allow --failure-level option to be set to default value, FATAL, and update description in help
-rw-r--r--CHANGELOG.adoc2
-rw-r--r--lib/asciidoctor/cli/options.rb2
-rw-r--r--test/options_test.rb15
3 files changed, 14 insertions, 5 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 92baab56..f74ba88d 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -59,6 +59,8 @@ Improvements::
* Remove unnecessary specificity in default stylesheet for styling p element inside list item
* Remove form styles from the default stylesheet (#4186)
* Remove obsolete gist embed styles from default stylesheet
+ * Allow `--failure-level` to be set to default value, `FATAL`
+ * Sort levels in help for `--failure-level` option in ascending order
Documentation::
diff --git a/lib/asciidoctor/cli/options.rb b/lib/asciidoctor/cli/options.rb
index 609b566d..53f8f7a3 100644
--- a/lib/asciidoctor/cli/options.rb
+++ b/lib/asciidoctor/cli/options.rb
@@ -122,7 +122,7 @@ module Asciidoctor
'may be specified more than once' do |path|
(self[:requires] ||= []).concat path.split ','
end
- opts.on '--failure-level LEVEL', %w(warning WARNING error ERROR info INFO), 'set minimum logging level that triggers non-zero exit code: [WARN, ERROR, INFO] (default: FATAL)' do |level|
+ opts.on '--failure-level LEVEL', %w(info INFO warning WARNING error ERROR fatal FATAL), 'set minimum log level that yields a non-zero exit code: [INFO, WARN, ERROR, FATAL] (default: FATAL)' do |level|
level = 'WARN' if (level = level.upcase) == 'WARNING'
self[:failure_level] = ::Logger::Severity.const_get level
end
diff --git a/test/options_test.rb b/test/options_test.rb
index fcfb233a..c57e43c0 100644
--- a/test/options_test.rb
+++ b/test/options_test.rb
@@ -242,20 +242,27 @@ context 'Options' do
assert_equal ::Logger::Severity::FATAL, options[:failure_level]
end
- test 'should allow failure level to be set to WARN' do
- %w(w warn WARN warning WARNING).each do |val|
+ test 'should allow failure level to be set to FATAL using any recognized abbreviation' do
+ %w(f fatal FATAL).each do |val|
options = Asciidoctor::Cli::Options.parse! %W(--failure-level=#{val} test/fixtures/sample.adoc)
- assert_equal ::Logger::Severity::WARN, options[:failure_level]
+ assert_equal ::Logger::Severity::FATAL, options[:failure_level]
end
end
- test 'should allow failure level to be set to ERROR' do
+ test 'should allow failure level to be set to ERROR using any recognized abbreviation' do
%w(e err ERR error ERROR).each do |val|
options = Asciidoctor::Cli::Options.parse! %W(--failure-level=#{val} test/fixtures/sample.adoc)
assert_equal ::Logger::Severity::ERROR, options[:failure_level]
end
end
+ test 'should allow failure level to be set to WARN using any recognized abbreviation' do
+ %w(w warn WARN warning WARNING).each do |val|
+ options = Asciidoctor::Cli::Options.parse! %W(--failure-level=#{val} test/fixtures/sample.adoc)
+ assert_equal ::Logger::Severity::WARN, options[:failure_level]
+ end
+ end
+
test 'should not allow failure level to be set to unknown value' do
exit_code, messages = redirect_streams do |_, err|
[(Asciidoctor::Cli::Options.parse! %w(--failure-level=foobar test/fixtures/sample.adoc)), err.string]