Skip to content

Commit

Permalink
feat: Add option to specify import package
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Mar 26, 2024
1 parent 564f750 commit 3b18292
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions capella_ros_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@ def cli():
"-l",
"--layer",
type=click.Choice(["oa", "la", "sa", "pa"], case_sensitive=False),
required=True,
help="The layer to import the messages to.",
)
@click.option(
"-r",
"--root",
type=str,
help="The UUID of the root package to import the messages to.",
)
@click.option(
"-t",
"--types",
type=str,
help="The UUID of the types package to import the created data types to.",
)
@click.option(
"--no-deps",
"no_deps",
Expand All @@ -63,13 +74,24 @@ def import_msgs(
input: str,
model: capellambse.MelodyModel,
layer: str,
root: str,
types: str,
no_deps: bool,
output: pathlib.Path,
) -> None:
"""Import ROS messages into a Capella data package."""

root_uuid = getattr(model, layer).data_package.uuid
types_uuid = model.sa.data_package.uuid
if root:
root_uuid = root
elif layer:
root_uuid = getattr(model, layer).data_package.uuid
else:
raise click.UsageError("Either --root or --layer must be provided")

if types:
types_uuid = types
else:
types_uuid = model.sa.data_package.uuid

parsed = importer.Importer(input, no_deps)
logger.info("Loaded %d packages", len(parsed.messages.packages))
Expand Down

0 comments on commit 3b18292

Please sign in to comment.