18 from importlib.metadata
import version
as getLibraryVersion
22 from .commands.login
import login
23 from .commands.model
import model
24 from .commands.node
import node
25 from .commands.task
import task
26 from .commands.project
import project
28 from .modules
import ui, utils
29 from .modules.intercept
import ClickExceptionInterceptor
30 from ..utils.process
import CommandException
34 def version() -> None:
35 version = getLibraryVersion(
"coretex")
36 ui.stdEcho(f
"Coretex {version}")
41 currentVersion = utils.fetchCurrentVersion()
42 latestVersion = utils.fetchLatestVersion()
44 if currentVersion
is None or latestVersion
is None:
47 if latestVersion > currentVersion:
49 ui.progressEcho(
"Updating coretex...")
52 f
"Coretex successfully updated from {utils.formatCliVersion(currentVersion)} "
53 f
"to {utils.formatCliVersion(latestVersion)}!"
55 except CommandException:
56 ui.errorEcho(
"Failed to update coretex.")
58 ui.stdEcho(
"Coretex version is up to date.")
61 @click.group(cls = ClickExceptionInterceptor)
62 @utils.onBeforeCommandExecute(utils.checkLibVersion, excludeSubcommands = ["update"])
63 @click.version_option(getLibraryVersion("coretex"),
"--version",
"-v", message =
"Coretex %(version)s")
67 cli.add_command(login)
68 cli.add_command(model)
69 cli.add_command(project)
72 cli.add_command(version)
73 cli.add_command(update)