jdkman 0.2.2__tar.gz → 0.2.4__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.
- {jdkman-0.2.2 → jdkman-0.2.4}/PKG-INFO +1 -1
- {jdkman-0.2.2 → jdkman-0.2.4}/pyproject.toml +1 -1
- jdkman-0.2.4/src/jdkman/autocomplete.py +11 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/cli.py +25 -7
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/cli_dev.py +17 -3
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/cli_tools.py +3 -1
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/config.py +1 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/console.py +17 -15
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/registry.py +1 -1
- jdkman-0.2.4/src/jdkman/style/format_error.py +49 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/style/format_help.py +3 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/README.md +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/__init__.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/catalog.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/detect.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/installer.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/jvm_spec/__init__.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/jvm_spec/_base.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/jvm_spec/temurin.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/jvm_spec/zulu.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/mise.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/style/__init__.py +0 -0
- {jdkman-0.2.2 → jdkman-0.2.4}/src/jdkman/utils.py +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from jdkman.catalog import fetch_slugs
|
|
2
|
+
from jdkman.registry import get_installed
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def autocomplete_installed(incomplete: str):
|
|
6
|
+
return list(get_installed(sort=True).keys())
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def autocomplete_slugs(incomplete: str):
|
|
10
|
+
return list(fetch_slugs(sort=True).keys())
|
|
11
|
+
|
|
@@ -3,12 +3,13 @@ from typing import Annotated, cast
|
|
|
3
3
|
import click
|
|
4
4
|
import typer
|
|
5
5
|
|
|
6
|
+
from .autocomplete import autocomplete_installed, autocomplete_slugs
|
|
6
7
|
from .cli_dev import app as dev_app
|
|
7
8
|
from .cli_tools import app as tools_app
|
|
8
9
|
from .config import APP_VERSION, is_dev, FORCE_VERBOSE, init_dirs
|
|
9
10
|
from .console import (
|
|
10
11
|
update_state, log, out, table,
|
|
11
|
-
GREEN_CHECK, ORANGE_WARNING, RED_WARNING,
|
|
12
|
+
GREEN_CHECK, ORANGE_WARNING, RED_WARNING,
|
|
12
13
|
st_emp, st_div, st_nor
|
|
13
14
|
)
|
|
14
15
|
from .installer import install_jvm, uninstall_jvm, upgrade_jvm
|
|
@@ -16,9 +17,8 @@ from .registry import list_vendors, get_slugs, get_outdated, cleanup_cache, get_
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
app = typer.Typer(
|
|
19
|
-
add_completion=
|
|
20
|
-
|
|
21
|
-
rich_markup_mode="rich",
|
|
20
|
+
add_completion=True,
|
|
21
|
+
pretty_exceptions_enable=is_dev()
|
|
22
22
|
)
|
|
23
23
|
app.add_typer(
|
|
24
24
|
tools_app
|
|
@@ -186,7 +186,13 @@ def outdated():
|
|
|
186
186
|
@app.command(name="setup", hidden=True, no_args_is_help=True)
|
|
187
187
|
@app.command(name="add", hidden=True, no_args_is_help=True)
|
|
188
188
|
@app.command(no_args_is_help=True)
|
|
189
|
-
def install(
|
|
189
|
+
def install(
|
|
190
|
+
distro: Annotated[str, typer.Argument(
|
|
191
|
+
metavar="<DISTRO>",
|
|
192
|
+
help="JVM distribution name to install. (e.g. zulu-21, temurin-17)",
|
|
193
|
+
autocompletion=autocomplete_slugs
|
|
194
|
+
)]
|
|
195
|
+
):
|
|
190
196
|
"""
|
|
191
197
|
Install a JVM distribution. \\[aliases: setup, add]
|
|
192
198
|
|
|
@@ -204,7 +210,13 @@ def install(distro: ARGUMENT_SLUG):
|
|
|
204
210
|
@app.command(name="remove", hidden=True, no_args_is_help=True)
|
|
205
211
|
@app.command(name="rm", hidden=True, no_args_is_help=True)
|
|
206
212
|
@app.command(no_args_is_help=True)
|
|
207
|
-
def uninstall(
|
|
213
|
+
def uninstall(
|
|
214
|
+
distro: Annotated[str, typer.Argument(
|
|
215
|
+
metavar="<DISTRO>",
|
|
216
|
+
help="JVM distribution name to uninstall. (e.g. zulu-21, temurin-17)",
|
|
217
|
+
autocompletion=autocomplete_installed
|
|
218
|
+
)]
|
|
219
|
+
):
|
|
208
220
|
"""
|
|
209
221
|
Remove an installed JVM distribution. \\[aliases: remove, rm]
|
|
210
222
|
|
|
@@ -221,7 +233,13 @@ def uninstall(distro: ARGUMENT_SLUG):
|
|
|
221
233
|
|
|
222
234
|
@app.command(name="update", hidden=True, no_args_is_help=True)
|
|
223
235
|
@app.command(no_args_is_help=True)
|
|
224
|
-
def upgrade(
|
|
236
|
+
def upgrade(
|
|
237
|
+
distro: Annotated[str, typer.Argument(
|
|
238
|
+
metavar="<DISTRO>",
|
|
239
|
+
help="JVM distribution name to upgrade. (e.g. zulu-21, temurin-17)",
|
|
240
|
+
autocompletion=autocomplete_installed
|
|
241
|
+
)]
|
|
242
|
+
):
|
|
225
243
|
"""
|
|
226
244
|
Upgrade an installed JVM distribution. \\[aliases: update]
|
|
227
245
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from collections import defaultdict
|
|
2
|
+
from typing import Annotated
|
|
2
3
|
|
|
3
4
|
import typer
|
|
4
5
|
|
|
6
|
+
from .autocomplete import autocomplete_slugs
|
|
5
7
|
from .catalog import fetch_artifacts
|
|
6
8
|
from .config import CACHE_DIR
|
|
7
|
-
from .console import
|
|
9
|
+
from .console import st_emp, st_nor
|
|
8
10
|
from .console import out, log, GREEN_CHECK
|
|
9
11
|
from .detect import scan_unmanaged
|
|
10
12
|
from .installer import download_jvm
|
|
@@ -55,7 +57,13 @@ def diff():
|
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
@app.command()
|
|
58
|
-
def download(
|
|
60
|
+
def download(
|
|
61
|
+
distro: Annotated[str, typer.Argument(
|
|
62
|
+
metavar="<DISTRO>",
|
|
63
|
+
help="JVM distribution name to download. (e.g. zulu-21, temurin-17)",
|
|
64
|
+
autocompletion=autocomplete_slugs
|
|
65
|
+
)]
|
|
66
|
+
):
|
|
59
67
|
"""
|
|
60
68
|
download_jvm(get_dist(distro))
|
|
61
69
|
"""
|
|
@@ -67,7 +75,13 @@ def download(distro: ARGUMENT_SLUG):
|
|
|
67
75
|
|
|
68
76
|
|
|
69
77
|
@app.command()
|
|
70
|
-
def slug(
|
|
78
|
+
def slug(
|
|
79
|
+
distro: Annotated[str, typer.Argument(
|
|
80
|
+
metavar="<DISTRO>",
|
|
81
|
+
help="JVM distribution name to get detail information. (e.g. zulu-21, temurin-17)",
|
|
82
|
+
autocompletion=autocomplete_slugs
|
|
83
|
+
)]
|
|
84
|
+
):
|
|
71
85
|
"""
|
|
72
86
|
get_slug(distro)
|
|
73
87
|
"""
|
|
@@ -2,6 +2,7 @@ from typing import Annotated
|
|
|
2
2
|
|
|
3
3
|
import typer
|
|
4
4
|
|
|
5
|
+
from .autocomplete import autocomplete_installed
|
|
5
6
|
from .config import is_macos
|
|
6
7
|
from .console import out, log, table, GREEN_CHECK, st_nor
|
|
7
8
|
from .detect import exec_java_home
|
|
@@ -40,7 +41,8 @@ if is_macos():
|
|
|
40
41
|
@app.command(rich_help_panel="Tools")
|
|
41
42
|
def mise(
|
|
42
43
|
distro: Annotated[str, typer.Argument(
|
|
43
|
-
help="JVM distribution name to register as a mise symlink. (omit to list)"
|
|
44
|
+
help="JVM distribution name to register as a mise symlink. (omit to list)",
|
|
45
|
+
autocompletion=autocomplete_installed
|
|
44
46
|
)] = None
|
|
45
47
|
):
|
|
46
48
|
"""
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
from typing import Any
|
|
2
3
|
|
|
3
4
|
import rich.box
|
|
4
|
-
import typer
|
|
5
5
|
from rich.console import Console
|
|
6
6
|
from rich.table import Table
|
|
7
7
|
from rich.text import Text
|
|
8
8
|
|
|
9
|
-
from .config import CUSTOM_STYLE_HELP, CUSTOM_STYLE_TABLE
|
|
9
|
+
from .config import CUSTOM_STYLE_HELP, CUSTOM_STYLE_ERROR, CUSTOM_STYLE_TABLE
|
|
10
|
+
from .style.format_error import ErrorFormatter
|
|
10
11
|
from .style.format_help import HelpFormatter
|
|
11
12
|
|
|
12
13
|
|
|
@@ -27,6 +28,12 @@ if CUSTOM_STYLE_HELP:
|
|
|
27
28
|
HelpFormatter(
|
|
28
29
|
section_header_style="bold yellow",
|
|
29
30
|
section_order=["commands", "arguments", "options"],
|
|
31
|
+
hidden_options={"--install-completion", "--show-completion"},
|
|
32
|
+
).apply()
|
|
33
|
+
|
|
34
|
+
if CUSTOM_STYLE_ERROR:
|
|
35
|
+
ErrorFormatter(
|
|
36
|
+
header_style="bold red",
|
|
30
37
|
).apply()
|
|
31
38
|
|
|
32
39
|
|
|
@@ -45,7 +52,7 @@ def out(*objs: Any, **kwargs: Any):
|
|
|
45
52
|
|
|
46
53
|
|
|
47
54
|
def log(*objs: Any, **kwargs: Any):
|
|
48
|
-
if not _state["verbose"]:
|
|
55
|
+
if not _state["verbose"] or "_JDK_COMPLETE" in os.environ:
|
|
49
56
|
return
|
|
50
57
|
prefix = Text.from_markup("[italic bright_black]verbose[/italic bright_black] ")
|
|
51
58
|
with _log_console.capture() as capture:
|
|
@@ -60,18 +67,13 @@ GREEN_CHECK = "[green]:heavy_check_mark:[/green]"
|
|
|
60
67
|
ORANGE_WARNING = "[orange3]:warning:[/orange3]"
|
|
61
68
|
RED_WARNING = "[red]:exclamation_question_mark:[/red]"
|
|
62
69
|
|
|
63
|
-
def st_emp(txt: str) -> str:
|
|
64
|
-
return f"[yellow]{txt}[/yellow]"
|
|
65
|
-
|
|
66
|
-
def st_div(txt: str) -> str:
|
|
67
|
-
return f"[cyan]{txt}[/cyan]"
|
|
68
70
|
|
|
69
|
-
def
|
|
70
|
-
return f"[
|
|
71
|
+
def st_emp(content: Any) -> str:
|
|
72
|
+
return f"[yellow]{content}[/yellow]"
|
|
71
73
|
|
|
74
|
+
def st_div(content: Any) -> str:
|
|
75
|
+
return f"[cyan]{content}[/cyan]"
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
help="JVM distribution name. (e.g. zulu-21, temurin-17)"
|
|
76
|
-
)]
|
|
77
|
+
def st_nor(content: Any) -> str:
|
|
78
|
+
return f"[grey70]{content}[/grey70]"
|
|
77
79
|
|
|
@@ -93,7 +93,7 @@ def list_editions() -> list[str]:
|
|
|
93
93
|
log(f"list_editions()")
|
|
94
94
|
|
|
95
95
|
# mise ls-remote java | grep -o '^[a-zA-Z0-9-]*-[a-zA-Z0-9]*' | sed 's/-[0-9].*//' | sort -u | grep -v '^$'
|
|
96
|
-
return list(dict.fromkeys(re.sub(r'-\d+$', '',
|
|
96
|
+
return list(dict.fromkeys(re.sub(r'-\d+$', '', slug) for slug in fetch_slugs(sort=True).keys()))
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def get_slugs(include_jre: bool, include_feature: bool, major_version: str | None) -> dict[str, dict[str, Any]]:
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
import typer
|
|
5
|
+
import typer.rich_utils
|
|
6
|
+
from rich.padding import Padding
|
|
7
|
+
from rich.text import Text
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class ErrorFormatter:
|
|
12
|
+
"""
|
|
13
|
+
- No Panel Box for errors
|
|
14
|
+
"""
|
|
15
|
+
header_style: str = "bold red"
|
|
16
|
+
|
|
17
|
+
def apply(self) -> None:
|
|
18
|
+
"""Patch typer globally with this style."""
|
|
19
|
+
typer.rich_utils.rich_format_error = self._build_formatter()
|
|
20
|
+
|
|
21
|
+
def _build_formatter(self):
|
|
22
|
+
style = self
|
|
23
|
+
|
|
24
|
+
def rich_format_error(exc: click.ClickException) -> None:
|
|
25
|
+
if exc.__class__.__name__ == "NoArgsIsHelpError":
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
_ru = typer.rich_utils
|
|
29
|
+
# noinspection PyProtectedMember
|
|
30
|
+
console = _ru._get_rich_console(stderr=True)
|
|
31
|
+
ctx: click.Context | None = getattr(exc, "ctx", None)
|
|
32
|
+
|
|
33
|
+
if ctx is not None:
|
|
34
|
+
console.print(ctx.get_usage())
|
|
35
|
+
|
|
36
|
+
if ctx is not None and ctx.command.get_help_option(ctx) is not None:
|
|
37
|
+
console.print(
|
|
38
|
+
_ru.RICH_HELP.format(
|
|
39
|
+
command_path=ctx.command_path,
|
|
40
|
+
help_option=ctx.help_option_names[0],
|
|
41
|
+
),
|
|
42
|
+
style=_ru.STYLE_ERRORS_SUGGESTION,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
console.print(Padding(Text(f"{_ru.ERRORS_PANEL_TITLE}:", style=style.header_style), (0, 1, 0, 0)))
|
|
46
|
+
console.print(Padding(_ru.highlighter(exc.format_message()), (0, 1, 0, 2)))
|
|
47
|
+
|
|
48
|
+
return rich_format_error
|
|
49
|
+
|
|
@@ -27,6 +27,7 @@ class HelpFormatter:
|
|
|
27
27
|
"""
|
|
28
28
|
section_header_style: str = "bold yellow"
|
|
29
29
|
section_order: list[Section] = field(default_factory=lambda: list(_DEFAULT_ORDER))
|
|
30
|
+
hidden_options: set[str] = field(default_factory=set)
|
|
30
31
|
|
|
31
32
|
def apply(self) -> None:
|
|
32
33
|
"""Patch typer globally with this style."""
|
|
@@ -97,6 +98,8 @@ class HelpFormatter:
|
|
|
97
98
|
for param in obj.get_params(ctx):
|
|
98
99
|
if getattr(param, "hidden", False):
|
|
99
100
|
continue
|
|
101
|
+
if isinstance(param, click.Option) and style.hidden_options.intersection(param.opts):
|
|
102
|
+
continue
|
|
100
103
|
pname = getattr(param, _ru._RICH_HELP_PANEL_NAME, None)
|
|
101
104
|
if isinstance(param, click.Argument):
|
|
102
105
|
panel_to_arguments[pname or _ru.ARGUMENTS_PANEL_TITLE].append(param)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|