Skip to content

Treat case when there are multiple matching commands when running mycli <cmd>#44

Merged
gcbeltramini merged 14 commits into
mainfrom
gb/ambiguous-command-name
Apr 26, 2026
Merged

Treat case when there are multiple matching commands when running mycli <cmd>#44
gcbeltramini merged 14 commits into
mainfrom
gb/ambiguous-command-name

Conversation

@gcbeltramini

Copy link
Copy Markdown
Owner

Also:

  • Treat case when grep does not match
  • Add variable definition
  • Add unit test for empty jupyter notebook
  • Add "return 1" in case the error function doesn't exit
  • Add print_error function
  • Improve logs and comment
  • Simplify if-else

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_error helper and updates CLI error outputs for missing/ambiguous commands.
  • Updates autocomplete helpers to avoid failing when grep filters out all lines.
  • Adds a unit test for handling an empty Jupyter notebook (cells: []) in ipynb_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.

Comment thread core/cli_root/cli_init.sh Outdated
Comment thread core/cli_root/cli_init.sh Outdated
Comment thread tests/core/helpers/test_python.sh Outdated
Comment thread core/cli_root/cli_init.sh

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread core/cli_root/cli_init.sh Outdated
Comment thread core/cli_root/cli_init.sh
Comment thread core/cli_root/cli_init.sh
Comment thread tests/core/helpers/test_python.sh

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread core/cli_root/cli_init.sh
Comment thread core/cli_root/cli_init.sh
@gcbeltramini gcbeltramini marked this pull request as ready for review April 26, 2026 16:16
@gcbeltramini gcbeltramini merged commit 516459a into main Apr 26, 2026
1 check passed
@gcbeltramini gcbeltramini deleted the gb/ambiguous-command-name branch April 26, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants