Add fzf-based interactive selection to ros2cli commands
Description
This PR adds optional fuzzy search functionality to ros2cli commands using fzf, inspired by the ros2-aliases project. When arguments are omitted from commands, an interactive fzf selector is launched instead of throwing an error.
Commands enhanced:
ros2 topic echo- Select topic interactivelyros2 topic hz- Select topic interactivelyros2 topic info- Select topic interactivelyros2 topic bw- Select topic interactivelyros2 topic pub- Select topic interactivelyros2 node info- Select node interactivelyros2 service call- Select service interactivelyros2 param get- Cascading selection (node → parameter)ros2 interface show- Select interface interactively
Implementation:
- Added
interactive_select()helper function inros2cli/helpers.py - Made positional arguments optional (
nargs='?') in affected verbs - Added fzf as an execution dependency in
ros2cli/package.xml - Maintains 100% backward compatibility - all existing command usage still works
Is this user-facing behavior change?
Yes. Users can now omit arguments and use fuzzy search instead:
Before:
ros2 topic echo /my_topic_name # Must know exact topic name
After:
ros2 topic echo # Launches fzf to select from available topics
ros2 topic echo /my_topic_name # Still works as before
If fzf is not installed, users get a clear error message directing them to install via rosdep.
Did you use Generative AI?
Yes, GitHub Copilot was used
Additional Information
- Requires fzf: Added as dependency in package.xml but dependent on https://github.com/ros/rosdistro/pull/49148
- No breaking changes: All existing CLI usage remains unchanged
- Graceful degradation: Clear error message if fzf is missing
This PR still needs some testing and refinement but before I iterate further I'd like to know if you would merge this idea in. Thanks @ahcorde @fujitatomoya You can see a gif demo in https://github.com/tonynajjar/ros2-aliases
Thanks for the feedback @fujitatomoya . Like you said I will start working on your comments once I get another opinion on the general idea, to make sure this can ultimately get merged in
Maybe @ahcorde you can give your general opinion on the feature and I can continue to iterate with @fujitatomoya? Thanks!
friendly ping @ahcorde