Skip to content

Fix flag name in --max-wait-time-secs help text in ros2 topic pub #1306

Description

@sloretz

In ros2topic/ros2topic/verb/pub.py, the help text for --max-wait-time-secs refers to --wait-until-matching-subscriptions, which does not exist. The actual argument name is --wait-matching-subscriptions.

Modify the following file to fix the option name in the help text:

  • ros2topic/ros2topic/verb/pub.py

Example: How to fix the help text

# Before:
parser.add_argument(
    '--max-wait-time-secs',
    dest='max_wait_time_secs', type=positive_float, default=None,
    help='This sets the maximum wait time in seconds if '
         '--wait-until-matching-subscriptions is set. '
         'By default, this flag is not set meaning the subscriber will wait endlessly.')

# After:
parser.add_argument(
    '--max-wait-time-secs',
    dest='max_wait_time_secs', type=positive_float, default=None,
    help='This sets the maximum wait time in seconds if '
         '--wait-matching-subscriptions is set. '
         'By default, this flag is not set meaning the subscriber will wait endlessly.')

Example: How to add a test

Add a test in ros2topic/test/ that checks the generated help output of PubVerb:

import argparse
from ros2topic.verb.pub import PubVerb


def test_pub_help_mentions_wait_matching_subscriptions():
    parser = argparse.ArgumentParser()
    verb = PubVerb()
    verb.add_arguments(parser, 'ros2 topic pub')
    help_text = parser.format_help()
    assert '--wait-matching-subscriptions' in help_text
    assert '--wait-until-matching-subscriptions' not in help_text

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions