kd-cli 2.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kd/__init__.py +45 -0
- kd/api/__init__.py +15 -0
- kd/api/articles.py +232 -0
- kd/api/http.py +234 -0
- kd/api/hub.py +69 -0
- kd/api/saved_queries.py +76 -0
- kd/api/tags.py +107 -0
- kd/api/youtrack.py +414 -0
- kd/article_marker.py +348 -0
- kd/auth.py +96 -0
- kd/cli/__init__.py +5 -0
- kd/cli/core/__init__.py +25 -0
- kd/cli/core/command_base.py +133 -0
- kd/cli/core/command_parser.py +246 -0
- kd/cli/core/namespaces.py +175 -0
- kd/cli/core/option_registry.py +265 -0
- kd/cli/input.py +42 -0
- kd/cli/main.py +612 -0
- kd/cli/namespaces/__init__.py +38 -0
- kd/cli/namespaces/alias/__init__.py +87 -0
- kd/cli/namespaces/article/__init__.py +843 -0
- kd/cli/namespaces/init.py +42 -0
- kd/cli/namespaces/issue/__init__.py +959 -0
- kd/cli/namespaces/primer/__init__.py +337 -0
- kd/cli/namespaces/project/__init__.py +243 -0
- kd/cli/namespaces/query/__init__.py +465 -0
- kd/cli/namespaces/search/__init__.py +82 -0
- kd/cli/namespaces/system/__init__.py +528 -0
- kd/cli/namespaces/tag/__init__.py +337 -0
- kd/cli/namespaces/time/__init__.py +307 -0
- kd/cli/namespaces/user/__init__.py +99 -0
- kd/cli/output.py +287 -0
- kd/cli/tree.py +65 -0
- kd/client.py +1953 -0
- kd/config.py +853 -0
- kd/connection.py +156 -0
- kd/debug.py +107 -0
- kd/exceptions.py +189 -0
- kd/history.py +169 -0
- kd/models/__init__.py +75 -0
- kd/models/article.py +64 -0
- kd/models/assist.py +47 -0
- kd/models/attachment.py +20 -0
- kd/models/comment.py +25 -0
- kd/models/common.py +39 -0
- kd/models/issue.py +67 -0
- kd/models/project.py +60 -0
- kd/models/saved_query.py +54 -0
- kd/models/search.py +20 -0
- kd/models/tag.py +30 -0
- kd/models/user.py +42 -0
- kd/models/work_item.py +59 -0
- kd/primer.py +231 -0
- kd/query_parser.py +181 -0
- kd/resources/__init__.py +1 -0
- kd/resources/command-synonyms.yaml +19 -0
- kd/resources/config-template.yaml +71 -0
- kd/resources/error-messages.yaml +101 -0
- kd_cli-2.0.4.dist-info/METADATA +149 -0
- kd_cli-2.0.4.dist-info/RECORD +64 -0
- kd_cli-2.0.4.dist-info/WHEEL +5 -0
- kd_cli-2.0.4.dist-info/entry_points.txt +2 -0
- kd_cli-2.0.4.dist-info/licenses/LICENSE +21 -0
- kd_cli-2.0.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Alias namespace: /alias
|
|
2
|
+
|
|
3
|
+
Commands: list, show
|
|
4
|
+
Displays and inspects user-defined command aliases from config.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from kd.cli.core.command_base import Command, CommandResult
|
|
12
|
+
from kd.cli.core.namespaces import Namespace
|
|
13
|
+
from kd.cli.core.option_registry import ResolvedOptions
|
|
14
|
+
from kd.config import resolve_config
|
|
15
|
+
from kd.exceptions import ValidationError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AliasListCommand(Command):
|
|
19
|
+
"""List all defined aliases."""
|
|
20
|
+
|
|
21
|
+
def __init__(self) -> None:
|
|
22
|
+
super().__init__(
|
|
23
|
+
"list",
|
|
24
|
+
"List all defined aliases with their expansions",
|
|
25
|
+
usage="kd /alias list",
|
|
26
|
+
examples=[
|
|
27
|
+
"kd /alias list",
|
|
28
|
+
"kd /alias list --output json",
|
|
29
|
+
],
|
|
30
|
+
see_also=["/alias show"],
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def execute(
|
|
34
|
+
self, args: list[str], options: ResolvedOptions, client: Any = None
|
|
35
|
+
) -> CommandResult:
|
|
36
|
+
rc = resolve_config()
|
|
37
|
+
rows: list[dict[str, str]] = []
|
|
38
|
+
seen: set[str] = set()
|
|
39
|
+
for source_label, aliases in [("local", rc.local_aliases), ("global", rc.global_aliases)]:
|
|
40
|
+
for name, command in sorted(aliases.items()):
|
|
41
|
+
if name in seen:
|
|
42
|
+
continue
|
|
43
|
+
seen.add(name)
|
|
44
|
+
rows.append({"name": name, "command": command, "source": source_label})
|
|
45
|
+
return rows
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AliasShowCommand(Command):
|
|
49
|
+
"""Show the expansion for a single alias."""
|
|
50
|
+
|
|
51
|
+
def __init__(self) -> None:
|
|
52
|
+
super().__init__(
|
|
53
|
+
"show",
|
|
54
|
+
"Show what an alias expands to",
|
|
55
|
+
usage="kd /alias show NAME",
|
|
56
|
+
examples=[
|
|
57
|
+
"kd /alias show my-bugs",
|
|
58
|
+
],
|
|
59
|
+
see_also=["/alias list"],
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def execute(
|
|
63
|
+
self, args: list[str], options: ResolvedOptions, client: Any = None
|
|
64
|
+
) -> CommandResult:
|
|
65
|
+
if not args:
|
|
66
|
+
raise ValidationError("Usage: kd /alias show NAME")
|
|
67
|
+
name = args[0]
|
|
68
|
+
rc = resolve_config()
|
|
69
|
+
|
|
70
|
+
# Check local first (higher priority), then global
|
|
71
|
+
if name in rc.local_aliases:
|
|
72
|
+
return {"name": name, "command": rc.local_aliases[name], "source": "local"}
|
|
73
|
+
if name in rc.global_aliases:
|
|
74
|
+
return {"name": name, "command": rc.global_aliases[name], "source": "global"}
|
|
75
|
+
|
|
76
|
+
defined = sorted(rc.aliases.keys())
|
|
77
|
+
if defined:
|
|
78
|
+
raise ValidationError(f"No alias named '{name}'. Defined aliases: {', '.join(defined)}")
|
|
79
|
+
raise ValidationError(f"No alias named '{name}'. No aliases defined in config.")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def create_alias_namespace() -> Namespace:
|
|
83
|
+
"""Build the /alias namespace."""
|
|
84
|
+
ns = Namespace("alias", "Command aliases", path="alias")
|
|
85
|
+
ns.register_command("list", AliasListCommand())
|
|
86
|
+
ns.register_command("show", AliasShowCommand())
|
|
87
|
+
return ns
|