16
16
17
17
from rosidl_cli .command import Command
18
18
19
- from .extensions import load_type_extensions
20
- from .extensions import load_typesupport_extensions
19
+ from .api import generate
21
20
22
21
23
22
class GenerateCommand (Command ):
@@ -27,17 +26,17 @@ class GenerateCommand(Command):
27
26
28
27
def add_arguments (self , parser ):
29
28
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 '.'." ))
34
33
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 = [],
37
36
help = 'Target type representations for generation.' )
38
37
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 = [],
41
40
help = 'Target type supports for generation.' )
42
41
parser .add_argument (
43
42
'-I' , '--include-path' , type = pathlib .Path , metavar = 'PATH' ,
@@ -47,36 +46,16 @@ def add_arguments(self, parser):
47
46
'package_name' , help = 'Name of the package to generate code for' )
48
47
parser .add_argument (
49
48
'interface_files' , metavar = 'interface_file' , nargs = '+' ,
50
- help = ('Normalized relative path to interface definition file. '
49
+ help = ('Relative path to an interface definition file. '
51
50
"If prefixed by another path followed by a colon ':', "
52
51
'path resolution is performed against such path.' ))
53
52
54
53
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