Tab completion for launch file arguments

Open
#595 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start by reading the ros2 launch command and its argument completion setup, then trace how launch files expose argument defaults and choices. The issue asks for completion of argument names and allowed choice values for both package launch files and file paths, across relevant shells. Done means both examples complete as requested; the issue does not name files or tests, so locate the existing completion tests before estimating coverage.

Written by the indexing model from the issue text.

Description

enhancement
Description

I would like to be able to tab-complete for launch file arguments. For example

<launch>
  <arg name="mode" default="fast" description="Operating mode">
    <choice value="slow"/>
    <choice value="medium"/>
    <choice value="fast"/>
  </arg>
  <arg name="namespace" default="demo"
       description="Namespace for the talker node"/>
  <arg name="use_sim_time" default="false" description="Use simulation time">
    <choice value="true"/>
    <choice value="false"/>
  </arg>

  <node pkg="demo_nodes_cpp" exec="talker" namespace="$(var namespace)">
    <param name="use_sim_time" value="$(var use_sim_time)"/>
  </node>
</launch>

I would like that

ros2 launch example.launch.xml <TAB>

prints

use_sim_time:=  namespace:=  mode:=

and

ros2 launch example.launch.xml mode:=<TAB>

prints

mode:=medium  mode:=fast  mode:=slow

Note: I'm on ZSH, so on bash things might be different, such as <TAB><TAB> and all args in a row and such.

Motivation

Often, I use launch files with arguments that I know, but I don't know exactly how they were written. Tab completion would help there tremendously, where the alternative approach would be cancelling the current launch, call it with --show-args, scroll through a potentially long list of arguments and then continue.

It would be especially useful if launch files use choice statements, e.g. if a robot startup file can be used for multiple models.

Design / Implementation Considerations

Obviously, things should work for all relevant shells (which will be probably easy to achieve since it's using python's argcomplete) and it should work for both ros2 launch <package> <launch_file_in_package> and ros2 launch <launch_file_path>.

I do have a working prototype running locally and I would be happy to work on this. I just wanted to straighten out the requirements first, before blindly opening a PR.

A screencast of my PoC:

https://github.com/user-attachments/assets/3240318a-942a-4dd3-bac8-a288fbbbe6a2

Additional Information

No response

Dominant language
Python
Stars
84
Forks
115
Avg merge
2d 1h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ros2/launch_ros

All issues in ros2/launch_ros

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.