Treat case when there are multiple matching commands when running mycli <cmd>#44
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves CLI robustness and UX around command discovery/help output, particularly when user-provided command prefixes match multiple commands, and adds tests for edge cases.
Changes:
- Adds
print_errorhelper and updates CLI error outputs for missing/ambiguous commands. - Updates autocomplete helpers to avoid failing when
grepfilters out all lines. - Adds a unit test for handling an empty Jupyter notebook (
cells: []) inipynb_cleanmetadata.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
core/cli_root/cli_init.sh |
Adds print_error; refactors command listing/ambiguity handling logic. |
core/cli_root/autocomplete_helpers.sh |
Makes grep-based filtering non-fatal when it yields no matches. |
core/helpers/files.sh |
Adds an explicit return 1 after exit_with_error in yaml2json. |
tests/core/helpers/test_python.sh |
Adds coverage for empty-notebook behavior in ipynb_cleanmetadata. |
tests/core/cli_root/test_autocomplete_helpers.sh |
Declares an additional local variable used by the test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
core/cli_root/cli_init.sh:94
- In the ambiguous-command path, the list of matches is printed to stdout (
echo "$command_path" | ... | sort). Since this is an error case and the preceding messages go to stderr, it would be more consistent (and easier to script against) to send the matches list to stderr as well.
echo >&2 "Multiple matches found"
echo >&2 "----------------------"
echo "$command_path" |
sed "s:${commands_dir}/:: ; s:\.sh$::" |
tr '/' ' ' |
sort
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
core/cli_root/cli_init.sh:95
- In the ambiguous-command branch, the list of matching commands is printed to stdout (
echo "$command_path" | … | sort). Since this is an error path (all surrounding messaging goes to stderr), this should also go to stderr to avoid breaking callers that rely on stdout for command output.
print_error "It was not possible to distinguish the commands."
echo >&2
echo >&2 "Multiple matches found"
echo >&2 "----------------------"
echo "$command_path" |
sed "s:${commands_dir}/:: ; s:\.sh$::" |
tr '/' ' ' |
sort
exit 1
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Also:
grepdoes not matchprint_errorfunction