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.
Files changed (64) hide show
  1. kd/__init__.py +45 -0
  2. kd/api/__init__.py +15 -0
  3. kd/api/articles.py +232 -0
  4. kd/api/http.py +234 -0
  5. kd/api/hub.py +69 -0
  6. kd/api/saved_queries.py +76 -0
  7. kd/api/tags.py +107 -0
  8. kd/api/youtrack.py +414 -0
  9. kd/article_marker.py +348 -0
  10. kd/auth.py +96 -0
  11. kd/cli/__init__.py +5 -0
  12. kd/cli/core/__init__.py +25 -0
  13. kd/cli/core/command_base.py +133 -0
  14. kd/cli/core/command_parser.py +246 -0
  15. kd/cli/core/namespaces.py +175 -0
  16. kd/cli/core/option_registry.py +265 -0
  17. kd/cli/input.py +42 -0
  18. kd/cli/main.py +612 -0
  19. kd/cli/namespaces/__init__.py +38 -0
  20. kd/cli/namespaces/alias/__init__.py +87 -0
  21. kd/cli/namespaces/article/__init__.py +843 -0
  22. kd/cli/namespaces/init.py +42 -0
  23. kd/cli/namespaces/issue/__init__.py +959 -0
  24. kd/cli/namespaces/primer/__init__.py +337 -0
  25. kd/cli/namespaces/project/__init__.py +243 -0
  26. kd/cli/namespaces/query/__init__.py +465 -0
  27. kd/cli/namespaces/search/__init__.py +82 -0
  28. kd/cli/namespaces/system/__init__.py +528 -0
  29. kd/cli/namespaces/tag/__init__.py +337 -0
  30. kd/cli/namespaces/time/__init__.py +307 -0
  31. kd/cli/namespaces/user/__init__.py +99 -0
  32. kd/cli/output.py +287 -0
  33. kd/cli/tree.py +65 -0
  34. kd/client.py +1953 -0
  35. kd/config.py +853 -0
  36. kd/connection.py +156 -0
  37. kd/debug.py +107 -0
  38. kd/exceptions.py +189 -0
  39. kd/history.py +169 -0
  40. kd/models/__init__.py +75 -0
  41. kd/models/article.py +64 -0
  42. kd/models/assist.py +47 -0
  43. kd/models/attachment.py +20 -0
  44. kd/models/comment.py +25 -0
  45. kd/models/common.py +39 -0
  46. kd/models/issue.py +67 -0
  47. kd/models/project.py +60 -0
  48. kd/models/saved_query.py +54 -0
  49. kd/models/search.py +20 -0
  50. kd/models/tag.py +30 -0
  51. kd/models/user.py +42 -0
  52. kd/models/work_item.py +59 -0
  53. kd/primer.py +231 -0
  54. kd/query_parser.py +181 -0
  55. kd/resources/__init__.py +1 -0
  56. kd/resources/command-synonyms.yaml +19 -0
  57. kd/resources/config-template.yaml +71 -0
  58. kd/resources/error-messages.yaml +101 -0
  59. kd_cli-2.0.4.dist-info/METADATA +149 -0
  60. kd_cli-2.0.4.dist-info/RECORD +64 -0
  61. kd_cli-2.0.4.dist-info/WHEEL +5 -0
  62. kd_cli-2.0.4.dist-info/entry_points.txt +2 -0
  63. kd_cli-2.0.4.dist-info/licenses/LICENSE +21 -0
  64. 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