Skip to content

Commit 8f93a59

Browse files
committed
update JSON scehame with command.catch_all.catch_help and add CI tests for scehams in fixtures
1 parent 65cf0c6 commit 8f93a59

File tree

8 files changed

+36
-22
lines changed

8 files changed

+36
-22
lines changed

lib/bashly/views/command/long_usage.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= view_marker
22

33
> if [[ -n "$long_usage" ]]; then
4-
= render(:usage_options).indent 2
4+
= render(:usage_options).indent 2 if flags.any? || fixed_flags?
55
= render(:usage_args).indent 2 if args.any? or catch_all.help
66
= render(:usage_environment_variables).indent 2 if environment_variables.any?
77
= render(:usage_examples).indent 2 if examples
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
= view_marker
22

3-
if flags.any? || fixed_flags?
4-
options_caption = strings[:options]
5-
if commands.any? && (public_flags.any? || (flags.any? && Settings.private_reveal_key))
6-
options_caption = strings[:global_options]
7-
end
8-
9-
> printf "%s\n" "{{ options_caption.color(:caption) }}"
10-
>
11-
= render(:usage_flags) if flags.any?
12-
= render(:usage_fixed_flags)
3+
options_caption = strings[:options]
4+
if commands.any? && (public_flags.any? || (flags.any? && Settings.private_reveal_key))
5+
options_caption = strings[:global_options]
136
end
7+
8+
> printf "%s\n" "{{ options_caption.color(:caption) }}"
9+
>
10+
= render(:usage_flags) if flags.any?
11+
= render(:usage_fixed_flags)

schemas/bashly.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@
683683
"description": "Whether the current argument or flag is required\nhttps://bashly.dev/configuration/command/#catch_all",
684684
"type": "boolean",
685685
"default": false
686+
},
687+
"catch_help": {
688+
"description": "Whether to also disable the --help flag and catch it like any other\nhttps://bashly.dev/configuration/command/#catch_all",
689+
"type": "boolean",
690+
"default": false
686691
}
687692
},
688693
"additionalProperties": false

spec/fixtures/workspaces/catch-all-including-help/test.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/usr/bin/env bash
22

3-
# This fixture tests that catch all with help is displayed even when the
4-
# configuration file does not have any args defined.
5-
# It is executed as part of the Runfile examples test
6-
# Reference issue: https://github.com/bashly-framework/bashly/issues/74
7-
83
rm -f ./cli
94

105
set -x

spec/fixtures/workspaces/catch-all-no-fixed-flags/test.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/usr/bin/env bash
22

3-
# This fixture tests that catch all with help is displayed even when the
4-
# configuration file does not have any args defined.
5-
# It is executed as part of the Runfile examples test
6-
# Reference issue: https://github.com/bashly-framework/bashly/issues/74
7-
83
rm -f ./cli
94

105
set -x

support/runfile/example.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ def examples
88
end
99

1010
def fixtures
11-
filter_dirs('spec/fixtures/workspaces').map { |dir| new dir, type: :fixture }
11+
filter_dirs('spec/fixtures/workspaces')
12+
.select { |dir| File.exist? "#{dir}/src/bashly.yml" }
13+
.map { |dir| new dir, type: :fixture }
1214
end
1315

1416
def all

support/runfile/schema.runfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ end
1616
help 'Run all the test actions in this runfile'
1717
action :all do
1818
check_examples
19+
check_fixtures
1920
check_settings
2021
check_strings
2122
check_arbitrary
@@ -46,6 +47,9 @@ action(:example) { |args| schema_check "examples/#{args['EXAMPLE']}/src/bashly.y
4647
help 'Test the bashly schema against all examples'
4748
action(:examples) { check_examples }
4849

50+
help 'Test the bashly schema against all workspace fixtures'
51+
action(:fixtures) { check_fixtures }
52+
4953
help 'Test the settings schema against the default settings template'
5054
action(:settings) { check_settings }
5155

@@ -68,6 +72,15 @@ helpers do
6872
say "\ngub`Examples PASS`"
6973
end
7074

75+
def check_fixtures
76+
say "\ngub`Fixtures`"
77+
Example.fixtures.each do |example|
78+
file = example.yaml_path
79+
schema_check file
80+
end
81+
say "\ngub`Examples PASS`"
82+
end
83+
7184
def check_settings
7285
say "\ngub`Settings schema`"
7386
file = 'lib/bashly/libraries/settings/settings.yml'

support/schema/bashly.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,12 @@ definitions:
581581
https://bashly.dev/configuration/command/#catch_all
582582
type: boolean
583583
default: false
584+
catch_help:
585+
description: |-
586+
Whether to also disable the --help flag and catch it like any other
587+
https://bashly.dev/configuration/command/#catch_all
588+
type: boolean
589+
default: false
584590
additionalProperties: false
585591
completions-property:
586592
title: completions

0 commit comments

Comments
 (0)