ros2cli icon indicating copy to clipboard operation
ros2cli copied to clipboard

Add fzf-based interactive selection to ros2cli commands

Open tonynajjar opened this issue 3 weeks ago • 3 comments

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 interactively
  • ros2 topic hz - Select topic interactively
  • ros2 topic info - Select topic interactively
  • ros2 topic bw - Select topic interactively
  • ros2 topic pub - Select topic interactively
  • ros2 node info - Select node interactively
  • ros2 service call - Select service interactively
  • ros2 param get - Cascading selection (node → parameter)
  • ros2 interface show - Select interface interactively

Implementation:

  • Added interactive_select() helper function in ros2cli/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

tonynajjar avatar Dec 21 '25 21:12 tonynajjar

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

tonynajjar avatar Dec 22 '25 10:12 tonynajjar

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

tonynajjar avatar Dec 26 '25 11:12 tonynajjar

Maybe @ahcorde you can give your general opinion on the feature and I can continue to iterate with @fujitatomoya? Thanks!

tonynajjar avatar Dec 29 '25 09:12 tonynajjar

friendly ping @ahcorde

tonynajjar avatar Jan 07 '26 11:01 tonynajjar