pltr-cli 0.2.0__tar.gz → 0.3.0__tar.gz

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 (96) hide show
  1. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/PKG-INFO +1 -1
  2. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/README.md +1 -0
  3. pltr_cli-0.3.0/docs/user-guide/aliases.md +257 -0
  4. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/pyproject.toml +1 -1
  5. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/__main__.py +3 -0
  6. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/cli.py +2 -0
  7. pltr_cli-0.3.0/src/pltr/commands/alias.py +241 -0
  8. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/ontology.py +2 -8
  9. pltr_cli-0.3.0/src/pltr/config/aliases.py +254 -0
  10. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/ontology.py +17 -18
  11. pltr_cli-0.3.0/src/pltr/utils/alias_resolver.py +56 -0
  12. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/utils/completion.py +8 -0
  13. pltr_cli-0.3.0/tests/test_commands/test_alias.py +225 -0
  14. pltr_cli-0.3.0/tests/test_config/test_aliases.py +220 -0
  15. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_services/test_ontology.py +15 -4
  16. pltr_cli-0.3.0/tests/test_utils/__init__.py +1 -0
  17. pltr_cli-0.3.0/tests/test_utils/test_alias_resolver.py +174 -0
  18. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/uv.lock +1 -1
  19. pltr_cli-0.2.0/DEVELOPMENT_PLAN.md +0 -620
  20. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/.github/workflows/ci.yml +0 -0
  21. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/.github/workflows/publish.yml +0 -0
  22. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/.github/workflows/test-publish.yml +0 -0
  23. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/.gitignore +0 -0
  24. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/.pre-commit-config.yaml +0 -0
  25. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/CLAUDE.md +0 -0
  26. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/LICENSE +0 -0
  27. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/README.md +0 -0
  28. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/api/wrapper.md +0 -0
  29. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/examples/gallery.md +0 -0
  30. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/user-guide/authentication.md +0 -0
  31. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/user-guide/commands.md +0 -0
  32. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/user-guide/quick-start.md +0 -0
  33. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/user-guide/troubleshooting.md +0 -0
  34. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/docs/user-guide/workflows.md +0 -0
  35. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/mypy.ini +0 -0
  36. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/scripts/release.py +0 -0
  37. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/__init__.py +0 -0
  38. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/auth/__init__.py +0 -0
  39. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/auth/base.py +0 -0
  40. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/auth/manager.py +0 -0
  41. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/auth/oauth.py +0 -0
  42. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/auth/storage.py +0 -0
  43. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/auth/token.py +0 -0
  44. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/__init__.py +0 -0
  45. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/admin.py +0 -0
  46. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/completion.py +0 -0
  47. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/configure.py +0 -0
  48. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/dataset.py +0 -0
  49. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/shell.py +0 -0
  50. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/sql.py +0 -0
  51. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/commands/verify.py +0 -0
  52. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/config/__init__.py +0 -0
  53. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/config/profiles.py +0 -0
  54. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/config/settings.py +0 -0
  55. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/__init__.py +0 -0
  56. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/admin.py +0 -0
  57. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/base.py +0 -0
  58. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/dataset.py +0 -0
  59. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/dataset_full.py +0 -0
  60. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/dataset_v2.py +0 -0
  61. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/services/sql.py +0 -0
  62. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/utils/__init__.py +0 -0
  63. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/utils/formatting.py +0 -0
  64. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/src/pltr/utils/progress.py +0 -0
  65. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/__init__.py +0 -0
  66. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/conftest.py +0 -0
  67. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/README.md +0 -0
  68. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/__init__.py +0 -0
  69. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/conftest.py +0 -0
  70. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/test_auth_flow.py +0 -0
  71. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/test_cli_integration.py +0 -0
  72. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/test_data_workflows.py +0 -0
  73. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/test_data_workflows_simple.py +0 -0
  74. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/integration/test_simple_integration.py +0 -0
  75. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_auth/__init__.py +0 -0
  76. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_auth/test_base.py +0 -0
  77. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_auth/test_manager.py +0 -0
  78. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_auth/test_oauth.py +0 -0
  79. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_auth/test_storage.py +0 -0
  80. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_auth/test_token.py +0 -0
  81. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/__init__.py +0 -0
  82. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_admin.py +0 -0
  83. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_completion.py +0 -0
  84. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_dataset.py +0 -0
  85. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_ontology.py +0 -0
  86. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_shell.py +0 -0
  87. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_sql.py +0 -0
  88. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_commands/test_verify_simple.py +0 -0
  89. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_config/__init__.py +0 -0
  90. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_config/test_profiles.py +0 -0
  91. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_config/test_settings.py +0 -0
  92. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_services/__init__.py +0 -0
  93. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_services/test_admin.py +0 -0
  94. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_services/test_base.py +0 -0
  95. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_services/test_dataset.py +0 -0
  96. {pltr_cli-0.2.0 → pltr_cli-0.3.0}/tests/test_services/test_sql.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pltr-cli
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Command-line interface for Palantir Foundry APIs
5
5
  Project-URL: Homepage, https://github.com/anjor/pltr-cli
6
6
  Project-URL: Repository, https://github.com/anjor/pltr-cli
@@ -8,6 +8,7 @@ Welcome to the pltr-cli documentation! This CLI tool provides a command-line int
8
8
  - **[Quick Start Guide](user-guide/quick-start.md)** - Get up and running in minutes
9
9
  - **[Authentication Setup](user-guide/authentication.md)** - Configure token and OAuth2 authentication
10
10
  - **[Command Reference](user-guide/commands.md)** - Complete reference for all 50+ commands
11
+ - **[Command Aliases](user-guide/aliases.md)** - Create shortcuts for frequently used commands
11
12
  - **[Common Workflows](user-guide/workflows.md)** - Real-world data analysis patterns
12
13
  - **[Troubleshooting](user-guide/troubleshooting.md)** - Common issues and solutions
13
14
 
@@ -0,0 +1,257 @@
1
+ # Command Aliases
2
+
3
+ Command aliases allow you to create shortcuts for frequently used commands, improving your productivity when working with pltr-cli.
4
+
5
+ ## Overview
6
+
7
+ Aliases are custom shortcuts that expand to full commands. They help you:
8
+ - Save time by reducing typing for common operations
9
+ - Create personalized workflows
10
+ - Simplify complex command sequences
11
+ - Build reusable command templates
12
+
13
+ ## Creating Aliases
14
+
15
+ ### Basic Alias
16
+
17
+ Create a simple alias with the `add` command:
18
+
19
+ ```bash
20
+ # Create an alias 'ds' for 'dataset get'
21
+ pltr alias add ds "dataset get"
22
+
23
+ # Now you can use:
24
+ pltr ds ri.foundry.main.dataset.123
25
+ # Instead of:
26
+ pltr dataset get ri.foundry.main.dataset.123
27
+ ```
28
+
29
+ ### Complex Aliases
30
+
31
+ Aliases can include options and arguments:
32
+
33
+ ```bash
34
+ # Create an alias for SQL queries with JSON output
35
+ pltr alias add jsonsql "sql execute --format json"
36
+
37
+ # Usage:
38
+ pltr jsonsql "SELECT * FROM table LIMIT 10"
39
+ ```
40
+
41
+ ### Overwriting Existing Aliases
42
+
43
+ Use the `--force` flag to overwrite an existing alias:
44
+
45
+ ```bash
46
+ pltr alias add ds "dataset list" --force
47
+ ```
48
+
49
+ ## Managing Aliases
50
+
51
+ ### List All Aliases
52
+
53
+ View all configured aliases:
54
+
55
+ ```bash
56
+ pltr alias list
57
+ ```
58
+
59
+ Output:
60
+ ```
61
+ ┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
62
+ ┃ Alias ┃ Command ┃
63
+ ┡━━━━━━━━━┩━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
64
+ │ ds │ dataset get │
65
+ │ jsonsql │ sql execute --format json │
66
+ │ onto │ ontology object-list │
67
+ └─────────┴─────────────────────────────┘
68
+ ```
69
+
70
+ ### Show Specific Alias
71
+
72
+ Display details of a single alias:
73
+
74
+ ```bash
75
+ pltr alias show ds
76
+ # Output: ds → dataset get
77
+ ```
78
+
79
+ ### Edit an Alias
80
+
81
+ Modify an existing alias:
82
+
83
+ ```bash
84
+ pltr alias edit ds "dataset create"
85
+ ```
86
+
87
+ ### Remove an Alias
88
+
89
+ Delete an alias you no longer need:
90
+
91
+ ```bash
92
+ pltr alias remove ds
93
+ # Or skip confirmation:
94
+ pltr alias remove ds --no-confirm
95
+ ```
96
+
97
+ ### Clear All Aliases
98
+
99
+ Remove all aliases at once:
100
+
101
+ ```bash
102
+ pltr alias clear
103
+ # Or skip confirmation:
104
+ pltr alias clear --no-confirm
105
+ ```
106
+
107
+ ## Advanced Features
108
+
109
+ ### Resolve Aliases
110
+
111
+ See what command an alias expands to:
112
+
113
+ ```bash
114
+ pltr alias resolve ds
115
+ # Output: ds → dataset get
116
+ ```
117
+
118
+ ### Export and Import
119
+
120
+ Export aliases to share with teammates or backup:
121
+
122
+ ```bash
123
+ # Export to file
124
+ pltr alias export --output my-aliases.json
125
+
126
+ # Export to stdout
127
+ pltr alias export
128
+ ```
129
+
130
+ Import aliases from a file:
131
+
132
+ ```bash
133
+ # Replace existing aliases
134
+ pltr alias import aliases.json
135
+
136
+ # Merge with existing aliases
137
+ pltr alias import aliases.json --merge
138
+ ```
139
+
140
+ ### Nested Aliases
141
+
142
+ Aliases can reference other aliases:
143
+
144
+ ```bash
145
+ pltr alias add d "dataset"
146
+ pltr alias add dg "d get"
147
+ # 'dg' expands to 'dataset get'
148
+ ```
149
+
150
+ ## Common Alias Examples
151
+
152
+ Here are some useful aliases to get you started:
153
+
154
+ ```bash
155
+ # Dataset operations
156
+ pltr alias add dsg "dataset get"
157
+ pltr alias add dsc "dataset create"
158
+
159
+ # SQL shortcuts
160
+ pltr alias add sq "sql execute"
161
+ pltr alias add sqj "sql execute --format json"
162
+ pltr alias add sqc "sql execute --format csv"
163
+ pltr alias add sqx "sql export"
164
+
165
+ # Ontology shortcuts
166
+ pltr alias add ol "ontology list"
167
+ pltr alias add oo "ontology object-list"
168
+ pltr alias add oget "ontology object-get"
169
+
170
+ # Admin shortcuts
171
+ pltr alias add ul "admin user list"
172
+ pltr alias add uc "admin user current"
173
+ pltr alias add gl "admin group list"
174
+
175
+ # Combined operations
176
+ pltr alias add quicksql "sql execute --format table --limit 100"
177
+ pltr alias add mydata "dataset get ri.foundry.main.dataset.my-favorite-dataset"
178
+ ```
179
+
180
+ ## Shell Integration
181
+
182
+ Aliases work seamlessly with shell completion and interactive mode:
183
+
184
+ ### Tab Completion
185
+
186
+ After installing shell completions, alias names are available for tab completion:
187
+
188
+ ```bash
189
+ pltr d<TAB>
190
+ # Shows: ds, dsc, dsg
191
+ ```
192
+
193
+ ### Interactive Shell
194
+
195
+ Aliases are available in the interactive shell:
196
+
197
+ ```bash
198
+ pltr shell
199
+ pltr> ds ri.foundry.main.dataset.123
200
+ # Expands to: dataset get ri.foundry.main.dataset.123
201
+ ```
202
+
203
+ ## Best Practices
204
+
205
+ 1. **Use meaningful names**: Choose alias names that are easy to remember
206
+ 2. **Keep it simple**: Avoid overly complex aliases that are hard to understand
207
+ 3. **Document your aliases**: Export and share team-standard aliases
208
+ 4. **Avoid conflicts**: Don't use names that conflict with existing commands
209
+ 5. **Test before sharing**: Verify aliases work correctly before distribution
210
+
211
+ ## Limitations
212
+
213
+ - Aliases cannot use reserved command names (configure, verify, dataset, etc.)
214
+ - Circular references are not allowed and will be detected
215
+ - Aliases are expanded only once (no recursive expansion)
216
+ - Maximum alias chain depth is 10 to prevent infinite loops
217
+
218
+ ## Configuration Storage
219
+
220
+ Aliases are stored in `~/.config/pltr/aliases.json` and persist across sessions. The file uses standard JSON format and can be manually edited if needed.
221
+
222
+ ## Troubleshooting
223
+
224
+ ### Alias Not Working
225
+
226
+ 1. Check if the alias exists:
227
+ ```bash
228
+ pltr alias show myalias
229
+ ```
230
+
231
+ 2. Verify the alias syntax:
232
+ ```bash
233
+ pltr alias resolve myalias
234
+ ```
235
+
236
+ 3. Test the expanded command directly:
237
+ ```bash
238
+ pltr <expanded command>
239
+ ```
240
+
241
+ ### Circular Reference Error
242
+
243
+ If you see a circular reference error, check your alias chain:
244
+
245
+ ```bash
246
+ # Example of circular reference (not allowed):
247
+ pltr alias add a "b"
248
+ pltr alias add b "a" # Error: would create circular reference
249
+ ```
250
+
251
+ ### Import Errors
252
+
253
+ When importing fails, check:
254
+ - File exists and is readable
255
+ - JSON format is valid
256
+ - No circular references in imported aliases
257
+ - No conflicts with reserved command names
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pltr-cli"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Command-line interface for Palantir Foundry APIs"
5
5
  authors = [
6
6
  { name = "anjor", email = "anjor@umd.edu" }
@@ -23,6 +23,9 @@ if "_PLTR_COMPLETE" in os.environ:
23
23
 
24
24
  # Normal CLI execution
25
25
  from pltr.cli import app
26
+ from pltr.utils.alias_resolver import inject_alias_resolution
26
27
 
27
28
  if __name__ == "__main__":
29
+ # Resolve aliases before running the app
30
+ inject_alias_resolution()
28
31
  app()
@@ -15,6 +15,7 @@ from pltr.commands import (
15
15
  admin,
16
16
  shell,
17
17
  completion,
18
+ alias,
18
19
  )
19
20
 
20
21
  app = typer.Typer(
@@ -36,6 +37,7 @@ app.add_typer(
36
37
  )
37
38
  app.add_typer(shell.shell_app, name="shell", help="Interactive shell mode")
38
39
  app.add_typer(completion.app, name="completion", help="Manage shell completions")
40
+ app.add_typer(alias.app, name="alias", help="Manage command aliases")
39
41
 
40
42
 
41
43
  def version_callback(value: bool):
@@ -0,0 +1,241 @@
1
+ """Command alias management commands."""
2
+
3
+ import json
4
+ from typing import Optional
5
+
6
+ import typer
7
+ from rich import print as rprint
8
+
9
+ from pltr.config.aliases import AliasManager
10
+ from pltr.utils.completion import complete_alias_names
11
+
12
+ app = typer.Typer(name="alias", help="Manage command aliases", no_args_is_help=True)
13
+
14
+
15
+ @app.command()
16
+ def add(
17
+ name: str = typer.Argument(..., help="Alias name"),
18
+ command: str = typer.Argument(..., help="Command to alias"),
19
+ force: bool = typer.Option(False, "--force", "-f", help="Overwrite existing alias"),
20
+ ) -> None:
21
+ """Create a new command alias."""
22
+ manager = AliasManager()
23
+
24
+ # Check if alias already exists
25
+ if manager.get_alias(name) and not force:
26
+ rprint(f"[red]Alias '{name}' already exists. Use --force to overwrite.[/red]")
27
+ raise typer.Exit(1)
28
+
29
+ # Check for reserved command names
30
+ reserved_commands = [
31
+ "configure",
32
+ "verify",
33
+ "dataset",
34
+ "ontology",
35
+ "sql",
36
+ "admin",
37
+ "shell",
38
+ "completion",
39
+ "alias",
40
+ "help",
41
+ "--version",
42
+ ]
43
+ if name in reserved_commands:
44
+ rprint(f"[red]Cannot use reserved command name '{name}' as alias[/red]")
45
+ raise typer.Exit(1)
46
+
47
+ try:
48
+ if force and manager.get_alias(name):
49
+ success = manager.edit_alias(name, command)
50
+ action = "Updated"
51
+ else:
52
+ success = manager.add_alias(name, command)
53
+ action = "Created"
54
+
55
+ if success:
56
+ rprint(f"[green]{action} alias:[/green] {name} → {command}")
57
+ else:
58
+ rprint(f"[red]Failed to create alias '{name}'[/red]")
59
+ raise typer.Exit(1)
60
+ except ValueError as e:
61
+ rprint(f"[red]Error: {e}[/red]")
62
+ raise typer.Exit(1)
63
+
64
+
65
+ @app.command()
66
+ def remove(
67
+ name: str = typer.Argument(
68
+ ..., help="Alias name to remove", autocompletion=complete_alias_names
69
+ ),
70
+ confirm: bool = typer.Option(
71
+ True, "--confirm/--no-confirm", help="Confirm removal"
72
+ ),
73
+ ) -> None:
74
+ """Remove a command alias."""
75
+ manager = AliasManager()
76
+
77
+ command = manager.get_alias(name)
78
+ if not command:
79
+ rprint(f"[red]Alias '{name}' not found[/red]")
80
+ raise typer.Exit(1)
81
+
82
+ if confirm:
83
+ confirmation = typer.confirm(f"Remove alias '{name}' → {command}?")
84
+ if not confirmation:
85
+ rprint("[yellow]Removal cancelled[/yellow]")
86
+ return
87
+
88
+ if manager.remove_alias(name):
89
+ rprint(f"[green]Removed alias '{name}'[/green]")
90
+ else:
91
+ rprint(f"[red]Failed to remove alias '{name}'[/red]")
92
+ raise typer.Exit(1)
93
+
94
+
95
+ @app.command()
96
+ def edit(
97
+ name: str = typer.Argument(
98
+ ..., help="Alias name to edit", autocompletion=complete_alias_names
99
+ ),
100
+ command: str = typer.Argument(..., help="New command for the alias"),
101
+ ) -> None:
102
+ """Edit an existing command alias."""
103
+ manager = AliasManager()
104
+
105
+ if not manager.get_alias(name):
106
+ rprint(f"[red]Alias '{name}' not found[/red]")
107
+ raise typer.Exit(1)
108
+
109
+ try:
110
+ if manager.edit_alias(name, command):
111
+ rprint(f"[green]Updated alias:[/green] {name} → {command}")
112
+ else:
113
+ rprint(f"[red]Failed to edit alias '{name}'[/red]")
114
+ raise typer.Exit(1)
115
+ except ValueError as e:
116
+ rprint(f"[red]Error: {e}[/red]")
117
+ raise typer.Exit(1)
118
+
119
+
120
+ @app.command("list")
121
+ def list_aliases() -> None:
122
+ """List all command aliases."""
123
+ manager = AliasManager()
124
+ manager.display_aliases()
125
+
126
+
127
+ @app.command()
128
+ def show(
129
+ name: str = typer.Argument(
130
+ ..., help="Alias name to show", autocompletion=complete_alias_names
131
+ ),
132
+ ) -> None:
133
+ """Show details of a specific alias."""
134
+ manager = AliasManager()
135
+ manager.display_aliases(name)
136
+
137
+
138
+ @app.command()
139
+ def clear(
140
+ confirm: bool = typer.Option(
141
+ True, "--confirm/--no-confirm", help="Confirm clearing all aliases"
142
+ ),
143
+ ) -> None:
144
+ """Clear all command aliases."""
145
+ manager = AliasManager()
146
+
147
+ aliases = manager.list_aliases()
148
+ if not aliases:
149
+ rprint("[yellow]No aliases to clear[/yellow]")
150
+ return
151
+
152
+ if confirm:
153
+ confirmation = typer.confirm(f"Clear all {len(aliases)} aliases?")
154
+ if not confirmation:
155
+ rprint("[yellow]Clear cancelled[/yellow]")
156
+ return
157
+
158
+ count = manager.clear_all()
159
+ rprint(f"[green]Cleared {count} aliases[/green]")
160
+
161
+
162
+ @app.command("export")
163
+ def export_aliases(
164
+ output: Optional[str] = typer.Option(
165
+ None, "--output", "-o", help="Output file (default: stdout)"
166
+ ),
167
+ ) -> None:
168
+ """Export aliases to JSON format."""
169
+ manager = AliasManager()
170
+ aliases = manager.export_aliases()
171
+
172
+ if not aliases:
173
+ rprint("[yellow]No aliases to export[/yellow]")
174
+ return
175
+
176
+ json_data = json.dumps(aliases, indent=2, sort_keys=True)
177
+
178
+ if output:
179
+ with open(output, "w") as f:
180
+ f.write(json_data)
181
+ rprint(f"[green]Exported {len(aliases)} aliases to {output}[/green]")
182
+ else:
183
+ print(json_data)
184
+
185
+
186
+ @app.command("import")
187
+ def import_aliases(
188
+ input_file: str = typer.Argument(..., help="JSON file containing aliases"),
189
+ merge: bool = typer.Option(
190
+ False, "--merge", "-m", help="Merge with existing aliases (default: replace)"
191
+ ),
192
+ ) -> None:
193
+ """Import aliases from a JSON file."""
194
+ manager = AliasManager()
195
+
196
+ try:
197
+ with open(input_file, "r") as f:
198
+ data = json.load(f)
199
+ except (json.JSONDecodeError, IOError) as e:
200
+ rprint(f"[red]Error reading file: {e}[/red]")
201
+ raise typer.Exit(1)
202
+
203
+ if not isinstance(data, dict):
204
+ rprint("[red]Invalid format: expected JSON object with alias mappings[/red]")
205
+ raise typer.Exit(1)
206
+
207
+ # Clear existing aliases if not merging
208
+ if not merge and manager.list_aliases():
209
+ confirmation = typer.confirm("Replace existing aliases?")
210
+ if not confirmation:
211
+ rprint("[yellow]Import cancelled[/yellow]")
212
+ return
213
+ manager.clear_all()
214
+
215
+ count = manager.import_aliases(data)
216
+ rprint(f"[green]Imported {count} aliases from {input_file}[/green]")
217
+
218
+
219
+ @app.command()
220
+ def resolve(
221
+ command: str = typer.Argument(
222
+ ..., help="Command to resolve", autocompletion=complete_alias_names
223
+ ),
224
+ ) -> None:
225
+ """Resolve an alias to show the actual command."""
226
+ manager = AliasManager()
227
+
228
+ resolved = manager.resolve_alias(command)
229
+ if resolved == command:
230
+ if command in manager.list_aliases():
231
+ rprint(
232
+ f"[yellow]'{command}' is an alias but may have circular references[/yellow]"
233
+ )
234
+ else:
235
+ rprint(f"[yellow]'{command}' is not an alias[/yellow]")
236
+ else:
237
+ rprint(f"[green]{command}[/green] → {resolved}")
238
+
239
+
240
+ if __name__ == "__main__":
241
+ app()
@@ -33,16 +33,13 @@ def list_ontologies(
33
33
  output: Optional[str] = typer.Option(
34
34
  None, "--output", "-o", help="Output file path"
35
35
  ),
36
- page_size: Optional[int] = typer.Option(
37
- None, "--page-size", help="Number of results per page"
38
- ),
39
36
  ):
40
37
  """List all available ontologies."""
41
38
  try:
42
39
  service = OntologyService(profile=profile)
43
40
 
44
41
  with SpinnerProgressTracker().track_spinner("Fetching ontologies..."):
45
- ontologies = service.list_ontologies(page_size=page_size)
42
+ ontologies = service.list_ontologies()
46
43
 
47
44
  formatter.format_table(
48
45
  ontologies,
@@ -106,16 +103,13 @@ def list_object_types(
106
103
  output: Optional[str] = typer.Option(
107
104
  None, "--output", "-o", help="Output file path"
108
105
  ),
109
- page_size: Optional[int] = typer.Option(
110
- None, "--page-size", help="Number of results per page"
111
- ),
112
106
  ):
113
107
  """List object types in an ontology."""
114
108
  try:
115
109
  service = ObjectTypeService(profile=profile)
116
110
 
117
111
  with SpinnerProgressTracker().track_spinner("Fetching object types..."):
118
- object_types = service.list_object_types(ontology_rid, page_size=page_size)
112
+ object_types = service.list_object_types(ontology_rid)
119
113
 
120
114
  formatter.format_table(
121
115
  object_types,