Skip to content

Commit 99653c7

Browse files
committed
Address second round of comments on f3d-app#2845
1 parent 349d042 commit 99653c7

File tree

6 files changed

+17
-29
lines changed

6 files changed

+17
-29
lines changed

.github/workflows/style-checks.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ jobs:
5656
prettier_options: "-w **/*.{js,json,md,html,yml}"
5757

5858
- name: Validate cli-options.json against schema
59-
uses: python-jsonschema/check-jsonschema@0.36.1
60-
with:
61-
files: "resources/cli-options.json"
62-
schema: "resources/cli-options.schema.json"
59+
shell: bash
60+
run: pipx run check-jsonschema==0.36.1 --schemafile resources/cli-options.schema.json resources/cli-options.json
6361

6462
- name: Echo Diff
6563
shell: bash

application/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,6 @@ if(UNIX AND NOT APPLE AND NOT ANDROID)
346346
install(FILES "${F3D_SOURCE_DIR}/resources/logo-mono.svg"
347347
DESTINATION "share/icons/HighContrast/scalable/apps" COMPONENT assets
348348
RENAME "f3d.svg")
349-
install(FILES
350-
"${F3D_SOURCE_DIR}/resources/cli-options.json"
351-
"${F3D_SOURCE_DIR}/resources/cli-options.schema.json"
352-
DESTINATION "${f3d_resources_dir}"
353-
COMPONENT shellext
354-
)
355349
install(FILES "${CMAKE_BINARY_DIR}/completion.bash"
356350
DESTINATION "share/bash-completion/completions" COMPONENT shellext
357351
RENAME "f3d")

application/F3DCLIOptions.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ struct CLIGroup
3333
std::vector<CLIOption> Options;
3434
};
3535

36+
/**
37+
* The CLIOptions array will be generated by CMake from
38+
* resources/cli-options.json. To add or update CLI options please update the
39+
* JSON file.
40+
*/
3641
// clang-format off
3742
@F3D_CLI_OPTIONS_CPP@
3843
// clang-format on

cmake/f3dCLIOptions.cmake

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ foreach(_si RANGE ${_last_surv})
152152

153153
# use the `*_json_error`s as an indicator of whether the key is present for this option
154154
if(_long_name_json_error)
155-
set(_long_name "")
155+
message(FATAL_ERROR "An option was found in ${F3D_SOURCE_DIR}/resources/cli-options.json without a long name")
156156
endif()
157157
if(_short_name_json_error)
158158
set(_short_name "")
@@ -176,26 +176,22 @@ foreach(_si RANGE ${_last_surv})
176176

177177
# generate completion file content for this CLI option
178178
if(F3D_CLI_OPTIONS_BASH)
179-
string(APPEND F3D_CLI_OPTIONS_BASH " ") # bash string uses space separator between options
179+
string(APPEND F3D_CLI_OPTIONS_BASH " ") # space separates completion options in bash array
180180
endif()
181181
if(F3D_CLI_OPTIONS_FISH)
182-
string(APPEND F3D_CLI_OPTIONS_FISH " \\\n") # fish uses a space, escape character, and newline to separate option commands
182+
string(APPEND F3D_CLI_OPTIONS_FISH "\n") # newline separates fish completion commands
183183
endif()
184184
if(F3D_CLI_OPTIONS_ZSH)
185-
string(APPEND F3D_CLI_OPTIONS_ZSH "\n") # zsh uses a new line to separate options in an array
185+
string(APPEND F3D_CLI_OPTIONS_ZSH "\n") # newline separates completion options in zsh array
186186
endif()
187187
if(_long_name AND _short_name)
188188
string(APPEND F3D_CLI_OPTIONS_BASH "--${_long_name} -${_short_name}")
189-
string(APPEND F3D_CLI_OPTIONS_FISH " 'complete -c f3d -l ${_long_name} -s ${_short_name} -d \"${_help_text}\"'")
189+
string(APPEND F3D_CLI_OPTIONS_FISH "complete -c f3d -l ${_long_name} -s ${_short_name} -d \"${_help_text}\"")
190190
string(APPEND F3D_CLI_OPTIONS_ZSH " '(-${_short_name} --${_long_name})'{-${_short_name},--${_long_name}}'[${_help_text}]'")
191-
elseif(_long_name)
191+
else() # _long_name must be set (checked earlier)
192192
string(APPEND F3D_CLI_OPTIONS_BASH "--${_long_name}")
193-
string(APPEND F3D_CLI_OPTIONS_FISH " 'complete -c f3d -l ${_long_name} -d \"${_help_text}\"'")
193+
string(APPEND F3D_CLI_OPTIONS_FISH "complete -c f3d -l ${_long_name} -d \"${_help_text}\"")
194194
string(APPEND F3D_CLI_OPTIONS_ZSH " '--${_long_name}[${_help_text}]'")
195-
elseif(_short_name)
196-
string(APPEND F3D_CLI_OPTIONS_BASH "-${_short_name}")
197-
string(APPEND F3D_CLI_OPTIONS_FISH " 'complete -c f3d -s ${_short_name} -d \"${_help_text}\"'")
198-
string(APPEND F3D_CLI_OPTIONS_ZSH " '--${_short_name}[${_help_text}]'")
199195
endif()
200196

201197
endforeach()

resources/cli-options.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@
4040
"properties": {
4141
"longName": {
4242
"type": "string",
43-
"minLength": 1,
43+
"minLength": 2,
4444
"description": "Long form of the option (e.g., 'help')"
4545
},
4646
"shortName": {
4747
"type": "string",
4848
"minLength": 1,
49+
"maxLength": 1,
4950
"description": "Short form of the option (e.g., 'h')"
5051
},
5152
"helpText": {
@@ -67,8 +68,7 @@
6768
"description": "Preprocessor definition that must be defined for this option to be available"
6869
}
6970
},
70-
"anyOf": [{ "required": ["longName"] }, { "required": ["shortName"] }],
71-
"required": ["helpText"],
71+
"required": ["longName", "helpText"],
7272
"additionalProperties": false
7373
}
7474
}

resources/completion.fish.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
set -l compl_cmds \
21
@F3D_CLI_OPTIONS_FISH@
3-
4-
for current_cmd in $compl_cmds
5-
eval $current_cmd
6-
end

0 commit comments

Comments
 (0)