Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial command line interface #12

Merged
merged 5 commits into from
Aug 9, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
get available topics
  • Loading branch information
Karsten1987 committed Jul 9, 2018
commit 0bc253d0f0ae986935717e3f1e3cec5a5f6d7297
15 changes: 13 additions & 2 deletions ros2bag/ros2bag/verb/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# limitations under the License.

import sys
import time

from ros2cli.node.strategy import add_arguments
from ros2cli.node.strategy import NodeStrategy

from ros2bag.verb import VerbExtension

Expand All @@ -21,6 +25,7 @@ class RecordVerb(VerbExtension):
"""ros2 bag record."""

def add_arguments(self, parser, cli_name): # noqa: D102
add_arguments(parser)
parser.add_argument(
'-a', '--all', action='store_true', help='recording all topics')
parser.add_argument(
Expand All @@ -31,5 +36,11 @@ def main(self, *, args): # noqa: D102
print('invalid choice: Can not specify topics and -a at the same time')
return

topics = 'all' if args.all else args.topics
print('topics to be recorded:', topics)
with NodeStrategy(args) as node:
if args.all:
t_and_n = node.get_topic_names_and_types()
print(t_and_n)
topics = [t for t,n in node.get_topic_names_and_types()]
if args.topics:
topics = args.topics
print('topics to be recorded:', topics)