File tree 2 files changed +40
-10
lines changed
2 files changed +40
-10
lines changed Original file line number Diff line number Diff line change @@ -24639,20 +24639,33 @@ HEREDOC
24639
24639
if ! hash bat 2>/dev/null
24640
24640
then
24641
24641
printf "bat required: https://github.com/sharkdp/bat\\n"
24642
+ elif [[ -z "${2:-}" ]]
24643
+ then
24644
+ return 1
24642
24645
else
24643
24646
local _theme_list=
24644
24647
_theme_list=($(bat --list-themes --color never))
24645
24648
24646
- if _contains "${2:-}" "${_theme_list[@]}"
24647
- then
24648
- return 0
24649
- else
24650
- _warn printf \
24651
- "%s must be one of the available themes.\\n" \
24652
- "${1}"
24649
+ local __theme=
24650
+ for __theme in "${_theme_list[@]}"
24651
+ do
24652
+ if [[ "${2}" =~ \( ]]
24653
+ then
24654
+ if [[ "${2}" == "${__theme:-}" ]]
24655
+ then
24656
+ return 0
24657
+ fi
24658
+ elif [[ "${2}" =~ ^${__theme%% (*} ]]
24659
+ then
24660
+ return 0
24661
+ fi
24662
+ done
24653
24663
24654
- return 1
24655
- fi
24664
+ _warn printf \
24665
+ "%s must be one of the available themes.\\n" \
24666
+ "${1}"
24667
+
24668
+ return 1
24656
24669
fi
24657
24670
else
24658
24671
return 0
Original file line number Diff line number Diff line change @@ -1184,7 +1184,7 @@ skip "Determine how to test interactive prompt."
1184
1184
[[ " $( " ${_NB} " settings get NB_SYNTAX_THEME) " == " Monokai Extended" ]]
1185
1185
}
1186
1186
1187
- @test " 'settings set syntax' with valid argument sets and exits." {
1187
+ @test " 'settings set syntax' with valid 'Solarized (dark)' argument sets and exits." {
1188
1188
{
1189
1189
" ${_NB} " init
1190
1190
}
@@ -1201,6 +1201,23 @@ skip "Determine how to test interactive prompt."
1201
1201
[[ " $( " ${_NB} " settings get NB_SYNTAX_THEME) " == " Solarized (dark)" ]]
1202
1202
}
1203
1203
1204
+ @test " 'settings set syntax' with valid 'Solarized (light)' argument sets and exits." {
1205
+ {
1206
+ " ${_NB} " init
1207
+ }
1208
+
1209
+ run " ${_NB} " settings set syntax " Solarized (light)"
1210
+
1211
+ printf " \$ {status}: '%s'\\ n" " ${status} "
1212
+ printf " \$ {output}: '%s'\\ n" " ${output} "
1213
+
1214
+ [[ ${status} -eq 0 ]]
1215
+ [[ " ${output} " =~ NB_SYNTAX_THEME ]]
1216
+ [[ " ${output} " =~ set\ to\ ]]
1217
+ [[ " ${output} " =~ Solarized\ \( light\) ]]
1218
+ [[ " $( " ${_NB} " settings get NB_SYNTAX_THEME) " == " Solarized (light)" ]]
1219
+ }
1220
+
1204
1221
@test " 'settings set NB_SYNTAX_THEME' with invalid argument exits with error." {
1205
1222
{
1206
1223
" ${_NB} " init
You can’t perform that action at this time.
0 commit comments