diff --git a/resotocore/resotocore/cli/command.py b/resotocore/resotocore/cli/command.py index 3881645679..6b1ab1313e 100644 --- a/resotocore/resotocore/cli/command.py +++ b/resotocore/resotocore/cli/command.py @@ -2549,7 +2549,6 @@ class ListCommand(CLICommand, OutputTransformer): + default_history_properties_to_show + default_live_properties_to_show } - dot_re = re.compile("[.]") @property def name(self) -> str: @@ -2600,7 +2599,8 @@ def default_props_to_show() -> List[Tuple[List[str], str]]: for name in chain(predicate_names, sort_names): if name not in self.all_default_props and name not in local_paths: local_paths.add(name) - result.append((self.dot_re.split(name), name.rsplit(".", 1)[-1])) + path = PropertyPath.from_path(name).unescaped_parts() + result.append((path, path[-1])) if ctx.query_options.get("history") is not True: result.extend(self.default_live_properties_to_show) # add all context properties @@ -2608,7 +2608,7 @@ def default_props_to_show() -> List[Tuple[List[str], str]]: return result def adjust_path(prop_path: str) -> List[str]: - return self.dot_re.split(ctx.variable_in_section(prop_path)) + return PropertyPath.from_path(ctx.variable_in_section(prop_path)).unescaped_parts() def to_str(name: str, elem: JsonElement) -> str: if isinstance(elem, dict): diff --git a/resotocore/resotocore/model/model.py b/resotocore/resotocore/model/model.py index 6bcf32af43..2b892cac4f 100644 --- a/resotocore/resotocore/model/model.py +++ b/resotocore/resotocore/model/model.py @@ -179,6 +179,9 @@ def child(self, part: Optional[str]) -> PropertyPath: update.append(part) return PropertyPath(update) + def unescaped_parts(self) -> List[str]: + return [p.strip("`") for p in self.path if p is not None] + @property def last_part(self) -> Optional[str]: return self.path[-1] if self.path else None diff --git a/resotocore/tests/resotocore/cli/command_test.py b/resotocore/tests/resotocore/cli/command_test.py index 54e53c3bf6..01a4fbe92f 100644 --- a/resotocore/tests/resotocore/cli/command_test.py +++ b/resotocore/tests/resotocore/cli/command_test.py @@ -584,7 +584,7 @@ async def test_list_command(cli: CLI) -> None: # List supports csv output result = await cli.execute_cli_command( - f"json {json.dumps(props)} | list --csv a,b,c,d,e,f,non_existent", stream.list + f"json {json.dumps(props)} | list --csv a,`b`,c,`d`,e,`f`,non_existent", stream.list ) assert result[0] == ['"a","b","c","d","e","f","non_existent"', '"a",True,False,"",12,1.234,""']