1616
1717from rosidl_cli .command import Command
1818
19- from .extensions import load_type_extensions
20- from .extensions import load_typesupport_extensions
19+ from .api import generate
2120
2221
2322class GenerateCommand (Command ):
@@ -27,17 +26,17 @@ class GenerateCommand(Command):
2726
2827 def add_arguments (self , parser ):
2928 parser .add_argument (
30- '-o' , '--output-path' , type = pathlib . Path ,
31- metavar = 'PATH' , default = pathlib . Path . cwd () ,
32- help = ('Path to directory to hold generated source code files. '
33- "Defaults to '.'." ))
29+ '-o' , '--output-path' , metavar = 'PATH' ,
30+ type = pathlib . Path , default = None ,
31+ help = ('Path to directory to hold generated '
32+ "source code files. Defaults to '.'." ))
3433 parser .add_argument (
35- '-t' , '--type' , metavar = 'TYPE_SPEC ' ,
36- dest = 'type_specs ' , action = 'append' , default = [],
34+ '-t' , '--type' , metavar = 'TYPE ' ,
35+ dest = 'types ' , action = 'append' , default = [],
3736 help = 'Target type representations for generation.' )
3837 parser .add_argument (
39- '-ts' , '--type-support' , metavar = 'TYPESUPPORT_SPEC ' ,
40- dest = 'typesupport_specs ' , action = 'append' , default = [],
38+ '-ts' , '--type-support' , metavar = 'TYPESUPPORT ' ,
39+ dest = 'typesupports ' , action = 'append' , default = [],
4140 help = 'Target type supports for generation.' )
4241 parser .add_argument (
4342 '-I' , '--include-path' , type = pathlib .Path , metavar = 'PATH' ,
@@ -47,36 +46,16 @@ def add_arguments(self, parser):
4746 'package_name' , help = 'Name of the package to generate code for' )
4847 parser .add_argument (
4948 'interface_files' , metavar = 'interface_file' , nargs = '+' ,
50- help = ('Normalized relative path to interface definition file. '
49+ help = ('Relative path to an interface definition file. '
5150 "If prefixed by another path followed by a colon ':', "
5251 'path resolution is performed against such path.' ))
5352
5453 def main (self , * , args ):
55- extensions = []
56-
57- unspecific_generation = \
58- not args .type_specs and not args .typesupport_specs
59-
60- if args .type_specs or unspecific_generation :
61- extensions .extend (load_type_extensions (
62- specs = args .type_specs ,
63- strict = not unspecific_generation ))
64-
65- if args .typesupport_specs or unspecific_generation :
66- extensions .extend (load_typesupport_extensions (
67- specs = args .typesupport_specs ,
68- strict = not unspecific_generation ))
69-
70- if unspecific_generation and not extensions :
71- return 'No type nor typesupport extensions were found'
72-
73- if len (extensions ) > 1 :
74- for extension in extensions :
75- extension .generate (
76- args .package_name , args .interface_files , args .include_paths ,
77- output_path = args .output_path / extension .name )
78- else :
79- extensions [0 ].generate (
80- args .package_name , args .interface_files ,
81- args .include_paths , args .output_path
82- )
54+ generate (
55+ package_name = args .package_name ,
56+ interface_files = args .interface_files ,
57+ include_paths = args .include_paths ,
58+ output_path = args .output_path ,
59+ types = args .types ,
60+ typesupports = args .typesupports
61+ )
0 commit comments