aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/client/paths.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/client/paths.py')
-rw-r--r--packages/meshbay-cli/src/meshbay_cli/client/paths.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/client/paths.py b/packages/meshbay-cli/src/meshbay_cli/client/paths.py
index 1086085..67119f9 100644
--- a/packages/meshbay-cli/src/meshbay_cli/client/paths.py
+++ b/packages/meshbay-cli/src/meshbay_cli/client/paths.py
@@ -50,6 +50,15 @@ def parse(text: str) -> RemotePath | None:
return RemotePath(decoded[0], decoded[1:], from_link)
+def group_arg(text: str) -> str:
+ """A group named on the command line, as `groups` prints it (`%2F` for a `/`),
+ or as a link to it: the name, decoded, with its `@owner` if given."""
+ path = parse(text)
+ if path is None or path.parts:
+ raise CliError(USAGE, f"Name a group, not a path: {text!r}")
+ return path.group
+
+
def encode_name(name: str) -> str:
"""A group or file name as it is typed in a path."""
return name.replace("%", "%25").replace("/", "%2F")