Skip to content

Conversation

@tonynajjar
Copy link

@tonynajjar tonynajjar commented Dec 21, 2025

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 type - Select topic interactively
  • ros2 node info - Select node 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 Add fzf ros/rosdistro#49148
  • No breaking changes: All existing CLI usage remains unchanged
  • Graceful degradation: Clear error message if fzf is missing

Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
@tonynajjar
Copy link
Author

tonynajjar commented Dec 22, 2025

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

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@tonynajjar generally i like this enhancement, thanks 🚀

there are several comments that i think we need to address but overall i think this is gonna be better user-experience for ROS 2 users and developers.

we already have type completion via shell command prompt but tab completion requires us to know the prefix and type sequentially from the beginning, while fzf lets us match any part of the name in any order (e.g., typing "wrist depth" finds /arm/wrist_camera/depth/image_raw). fzf also provides visual browsing of all available options with real-time filtering, making it ideal for exploring unfamiliar systems or when you only remember fragments of a name.

before fixing up my comments, let's hear out more feedback on this 👍

@tonynajjar
Copy link
Author

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
Copy link
Author

tonynajjar commented Dec 29, 2025

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

@tonynajjar
Copy link
Author

friendly ping @ahcorde

Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
@tonynajjar
Copy link
Author

@fujitatomoya I did a second round of fixes and am pretty happy with it so far but I invite you to test it out and find some bugs.

I'd like to note that there are probably more verbs that can benefit from an fzf integration like ros2 param set or ros2 topic pub but these require an additional input from the user in the end so slightly more complication (still manageable) - I would however get this first version in and I'm sure if people find it useful then they (or me) will be quick to contribute more fzf integrations

Signed-off-by: Tony Najjar <[email protected]>
Signed-off-by: Tony Najjar <[email protected]>
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

lgtm with green CI. just checking one last comment.

@fujitatomoya
Copy link
Collaborator

@ahcorde @InvincibleRMC i would like to have another approval on this before merge, can you take a look at this?

Copy link
Contributor

@InvincibleRMC InvincibleRMC left a comment

Choose a reason for hiding this comment

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

Some small questions

Signed-off-by: Tony Najjar <[email protected]>
@tonynajjar
Copy link
Author

Thanks for the second review. Some tests are failing because before this PR, verbs are expected to fail if no argument is given but now it's different. I will take a look at this next, hopefully pretty soon

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.

3 participants