knitpkg-mt 1.0.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 (58) hide show
  1. knitpkg_mt-1.0.0/LICENSE +21 -0
  2. knitpkg_mt-1.0.0/PKG-INFO +127 -0
  3. knitpkg_mt-1.0.0/README.md +98 -0
  4. knitpkg_mt-1.0.0/knitpkg/cli.py +104 -0
  5. knitpkg_mt-1.0.0/knitpkg/commands/add.py +93 -0
  6. knitpkg_mt-1.0.0/knitpkg/commands/autocomplete.py +87 -0
  7. knitpkg_mt-1.0.0/knitpkg/commands/build.py +176 -0
  8. knitpkg_mt-1.0.0/knitpkg/commands/checkinstall.py +90 -0
  9. knitpkg_mt-1.0.0/knitpkg/commands/compile.py +138 -0
  10. knitpkg_mt-1.0.0/knitpkg/commands/config.py +164 -0
  11. knitpkg_mt-1.0.0/knitpkg/commands/get.py +113 -0
  12. knitpkg_mt-1.0.0/knitpkg/commands/global_config.py +118 -0
  13. knitpkg_mt-1.0.0/knitpkg/commands/info.py +112 -0
  14. knitpkg_mt-1.0.0/knitpkg/commands/init.py +150 -0
  15. knitpkg_mt-1.0.0/knitpkg/commands/install.py +97 -0
  16. knitpkg_mt-1.0.0/knitpkg/commands/login.py +81 -0
  17. knitpkg_mt-1.0.0/knitpkg/commands/logout.py +69 -0
  18. knitpkg_mt-1.0.0/knitpkg/commands/register.py +102 -0
  19. knitpkg_mt-1.0.0/knitpkg/commands/search.py +169 -0
  20. knitpkg_mt-1.0.0/knitpkg/commands/status.py +81 -0
  21. knitpkg_mt-1.0.0/knitpkg/commands/telemetry.py +90 -0
  22. knitpkg_mt-1.0.0/knitpkg/commands/whoami.py +80 -0
  23. knitpkg_mt-1.0.0/knitpkg/commands/yank.py +84 -0
  24. knitpkg_mt-1.0.0/knitpkg/core/__init__.py +0 -0
  25. knitpkg_mt-1.0.0/knitpkg/core/auth.py +82 -0
  26. knitpkg_mt-1.0.0/knitpkg/core/cli_version.py +32 -0
  27. knitpkg_mt-1.0.0/knitpkg/core/config.py +106 -0
  28. knitpkg_mt-1.0.0/knitpkg/core/console.py +28 -0
  29. knitpkg_mt-1.0.0/knitpkg/core/constants.py +4 -0
  30. knitpkg_mt-1.0.0/knitpkg/core/dependency_downloader.py +629 -0
  31. knitpkg_mt-1.0.0/knitpkg/core/exceptions.py +230 -0
  32. knitpkg_mt-1.0.0/knitpkg/core/file_reading.py +158 -0
  33. knitpkg_mt-1.0.0/knitpkg/core/global_config.py +94 -0
  34. knitpkg_mt-1.0.0/knitpkg/core/lockfile.py +102 -0
  35. knitpkg_mt-1.0.0/knitpkg/core/models.py +255 -0
  36. knitpkg_mt-1.0.0/knitpkg/core/path_helper.py +48 -0
  37. knitpkg_mt-1.0.0/knitpkg/core/project_get.py +129 -0
  38. knitpkg_mt-1.0.0/knitpkg/core/project_manager.py +156 -0
  39. knitpkg_mt-1.0.0/knitpkg/core/project_register.py +280 -0
  40. knitpkg_mt-1.0.0/knitpkg/core/registry.py +408 -0
  41. knitpkg_mt-1.0.0/knitpkg/core/resolve_helper.py +13 -0
  42. knitpkg_mt-1.0.0/knitpkg/core/telemetry.py +44 -0
  43. knitpkg_mt-1.0.0/knitpkg/core/version_handling.py +72 -0
  44. knitpkg_mt-1.0.0/knitpkg/mql/__init__.py +19 -0
  45. knitpkg_mt-1.0.0/knitpkg/mql/autocomplete.py +167 -0
  46. knitpkg_mt-1.0.0/knitpkg/mql/build_header.py +200 -0
  47. knitpkg_mt-1.0.0/knitpkg/mql/compile.py +669 -0
  48. knitpkg_mt-1.0.0/knitpkg/mql/config.py +78 -0
  49. knitpkg_mt-1.0.0/knitpkg/mql/constants.py +10 -0
  50. knitpkg_mt-1.0.0/knitpkg/mql/dependency_downloader.py +55 -0
  51. knitpkg_mt-1.0.0/knitpkg/mql/exceptions.py +139 -0
  52. knitpkg_mt-1.0.0/knitpkg/mql/install.py +480 -0
  53. knitpkg_mt-1.0.0/knitpkg/mql/models.py +235 -0
  54. knitpkg_mt-1.0.0/knitpkg/mql/mql_paths.py +78 -0
  55. knitpkg_mt-1.0.0/knitpkg/mql/project_init.py +700 -0
  56. knitpkg_mt-1.0.0/knitpkg/mql/project_init_templates.py +1368 -0
  57. knitpkg_mt-1.0.0/knitpkg/mql/warnings.py +119 -0
  58. knitpkg_mt-1.0.0/pyproject.toml +50 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Douglas Rechia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: knitpkg-mt
3
+ Version: 1.0.0
4
+ Summary: KnitPkg for MetaTrader – Professional package manager for MQL5/MQL4
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Author: Douglas Rechia
8
+ Author-email: rechia@gmail.com
9
+ Requires-Python: >=3.13,<4.0
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: chardet (>=5.2.0,<6.0.0)
15
+ Requires-Dist: click (>=8.3.1,<9.0.0)
16
+ Requires-Dist: gitpython (>=3.1.45,<4.0.0)
17
+ Requires-Dist: httpx (>=0.28.1,<0.29.0)
18
+ Requires-Dist: jinja2 (>=3.1.6,<4.0.0)
19
+ Requires-Dist: keyring (>=25.7.0,<26.0.0)
20
+ Requires-Dist: packaging (>=25.0,<26.0)
21
+ Requires-Dist: pydantic (>=2.12.5,<3.0.0)
22
+ Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
23
+ Requires-Dist: rich (>=14.2.0,<15.0.0)
24
+ Requires-Dist: ruamel-yaml (>=0.19.1,<0.20.0)
25
+ Requires-Dist: semver (>=3.0.4,<4.0.0)
26
+ Requires-Dist: typer[all] (>=0.20.0,<0.21.0)
27
+ Description-Content-Type: text/markdown
28
+
29
+ # KnitPkg for MetaTrader (`kp`)
30
+
31
+ **A modern package & project manager for MQL5/MQL4 — built for real-world MetaTrader development.**
32
+
33
+ **KnitPkg** is a modern **package and project manager for MQL5/MQL4**, bringing an *npm-like* dependency workflow to real-world MetaTrader development.
34
+
35
+ MetaTrader projects often evolve through manual copy/paste, ad-hoc folder sharing, and “it works on my machine” dependency drift. KnitPkg exists to fix that by making code reuse and collaboration **predictable, reproducible, and automated**—without changing how MQL developers already publish code (Git repos).
36
+
37
+ - Home page: [knitpkg.dev](https://knitpkg.dev)
38
+ - Documentation: [docs.knitpkg.dev](https://docs.knitpkg.dev)
39
+ - Registry: [registry.knitpkg.dev](https://registry.knitpkg.dev)
40
+
41
+ ---
42
+
43
+ ## What KnitPkg is
44
+
45
+ KnitPkg is built around a **Git-first** model:
46
+
47
+ - Your code lives in **Git repositories** (Mql5Forge, GitHub, GitLab, Bitbucket).
48
+ - KnitPkg acts as a **metadata registry** that indexes projects via their manifests (it does **not** host your source or binaries).
49
+ - A **CLI tool** installs dependencies, resolves versions (SemVer + ranges), generates reproducible installs via a lock file, and can automate compilation.
50
+
51
+ The public registry API is available and currently operational.
52
+
53
+ ## Why developers use KnitPkg
54
+
55
+ KnitPkg focuses on the pain points that show up fast in MQL development:
56
+
57
+ - **Versioned dependencies** (SemVer + ranges like `^`, `~`, `<`, `>`, `*`, `!=`)
58
+ - **Reproducible builds** with a lock file
59
+ - **Composed packages** (dependency trees), including helpers like autocomplete and `@knitpkg:include`
60
+ - **Safe ecosystem maintenance** with *yanked* versions (removed from range resolution without breaking history)
61
+ - **Git-host login via OAuth** for publishing (no extra KnitPkg account); public installs need no auth
62
+
63
+ ---
64
+ ## Installation
65
+
66
+ Follow the [Installation section](https://docs.knitpkg.dev/installation/) of KnitPkg Documentation.
67
+
68
+ ---
69
+
70
+ ## Explore Seed Projects (Examples by the Author)
71
+
72
+ If you want real-world examples of how KnitPkg projects and reusable packages can be structured, you can explore the author’s public “seed” projects in the registry.
73
+
74
+ ### Option A) Search using the CLI
75
+
76
+ **MQL5 seeds:**
77
+
78
+ ```bash
79
+ kp search mql5 -o douglasrechia
80
+ ```
81
+
82
+ **MQL4 seeds:**
83
+
84
+ ```bash
85
+ kp search mql4 -o douglasrechia
86
+ ```
87
+
88
+ From the results, you can inspect details with `kp info`, or fetch and compile a project locally with `kp get`. <br>
89
+
90
+ ### Option B) Browse the registry website
91
+
92
+ As an alternative, you can browse the registry directly in your browser:
93
+
94
+ - **MQL5 seeds:** [registry.knitpkg.dev/mql5?org=douglasrechia](https://registry.knitpkg.dev/mql5?org=douglasrechia)
95
+ - **MQL4 seeds:** [registry.knitpkg.dev/mql4?org=douglasrechia](https://registry.knitpkg.dev/mql4?org=douglasrechia)
96
+
97
+
98
+ See [Getting started](https://docs.knitpkg.dev/getting-started/) for a quick introduction and first steps using KnitPkg.
99
+
100
+
101
+ ---
102
+
103
+ ## Support the Project
104
+
105
+ KnitPkg aims to strengthen the MQL ecosystem with better tooling. You can help keep the CLI and the **public registry** running by:
106
+
107
+ - Giving the repo a **GitHub star**
108
+ - Donating via **GitHub Sponsors / Donations** (not yet available)
109
+
110
+ ---
111
+
112
+ **KnitPkg — The dependency manager MQL always needed**
113
+
114
+ [Home page](https://knitpkg.dev/) - [Browse Registry](https://registry.knitpkg.dev/)
115
+
116
+ [X/Twitter](https://x.com/knitpkg) - [GitHub](https://github.com/knitpkg-dev/knitpkg-mt.git) - [Join Discord](https://discord.gg/bWvWpjw5m4) - [contact@knitpkg.dev](mailto:contact@knitpkg.dev)
117
+
118
+ MIT Licensed — Forever free for the community
119
+
120
+ **KnitPkg – The future of MQL5 development.**
121
+
122
+ ---
123
+
124
+ **DISCLAIMER:**
125
+ THE SOFTWARE IS PROVIDED **"AS IS"**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
126
+
127
+
@@ -0,0 +1,98 @@
1
+ # KnitPkg for MetaTrader (`kp`)
2
+
3
+ **A modern package & project manager for MQL5/MQL4 — built for real-world MetaTrader development.**
4
+
5
+ **KnitPkg** is a modern **package and project manager for MQL5/MQL4**, bringing an *npm-like* dependency workflow to real-world MetaTrader development.
6
+
7
+ MetaTrader projects often evolve through manual copy/paste, ad-hoc folder sharing, and “it works on my machine” dependency drift. KnitPkg exists to fix that by making code reuse and collaboration **predictable, reproducible, and automated**—without changing how MQL developers already publish code (Git repos).
8
+
9
+ - Home page: [knitpkg.dev](https://knitpkg.dev)
10
+ - Documentation: [docs.knitpkg.dev](https://docs.knitpkg.dev)
11
+ - Registry: [registry.knitpkg.dev](https://registry.knitpkg.dev)
12
+
13
+ ---
14
+
15
+ ## What KnitPkg is
16
+
17
+ KnitPkg is built around a **Git-first** model:
18
+
19
+ - Your code lives in **Git repositories** (Mql5Forge, GitHub, GitLab, Bitbucket).
20
+ - KnitPkg acts as a **metadata registry** that indexes projects via their manifests (it does **not** host your source or binaries).
21
+ - A **CLI tool** installs dependencies, resolves versions (SemVer + ranges), generates reproducible installs via a lock file, and can automate compilation.
22
+
23
+ The public registry API is available and currently operational.
24
+
25
+ ## Why developers use KnitPkg
26
+
27
+ KnitPkg focuses on the pain points that show up fast in MQL development:
28
+
29
+ - **Versioned dependencies** (SemVer + ranges like `^`, `~`, `<`, `>`, `*`, `!=`)
30
+ - **Reproducible builds** with a lock file
31
+ - **Composed packages** (dependency trees), including helpers like autocomplete and `@knitpkg:include`
32
+ - **Safe ecosystem maintenance** with *yanked* versions (removed from range resolution without breaking history)
33
+ - **Git-host login via OAuth** for publishing (no extra KnitPkg account); public installs need no auth
34
+
35
+ ---
36
+ ## Installation
37
+
38
+ Follow the [Installation section](https://docs.knitpkg.dev/installation/) of KnitPkg Documentation.
39
+
40
+ ---
41
+
42
+ ## Explore Seed Projects (Examples by the Author)
43
+
44
+ If you want real-world examples of how KnitPkg projects and reusable packages can be structured, you can explore the author’s public “seed” projects in the registry.
45
+
46
+ ### Option A) Search using the CLI
47
+
48
+ **MQL5 seeds:**
49
+
50
+ ```bash
51
+ kp search mql5 -o douglasrechia
52
+ ```
53
+
54
+ **MQL4 seeds:**
55
+
56
+ ```bash
57
+ kp search mql4 -o douglasrechia
58
+ ```
59
+
60
+ From the results, you can inspect details with `kp info`, or fetch and compile a project locally with `kp get`. <br>
61
+
62
+ ### Option B) Browse the registry website
63
+
64
+ As an alternative, you can browse the registry directly in your browser:
65
+
66
+ - **MQL5 seeds:** [registry.knitpkg.dev/mql5?org=douglasrechia](https://registry.knitpkg.dev/mql5?org=douglasrechia)
67
+ - **MQL4 seeds:** [registry.knitpkg.dev/mql4?org=douglasrechia](https://registry.knitpkg.dev/mql4?org=douglasrechia)
68
+
69
+
70
+ See [Getting started](https://docs.knitpkg.dev/getting-started/) for a quick introduction and first steps using KnitPkg.
71
+
72
+
73
+ ---
74
+
75
+ ## Support the Project
76
+
77
+ KnitPkg aims to strengthen the MQL ecosystem with better tooling. You can help keep the CLI and the **public registry** running by:
78
+
79
+ - Giving the repo a **GitHub star**
80
+ - Donating via **GitHub Sponsors / Donations** (not yet available)
81
+
82
+ ---
83
+
84
+ **KnitPkg — The dependency manager MQL always needed**
85
+
86
+ [Home page](https://knitpkg.dev/) - [Browse Registry](https://registry.knitpkg.dev/)
87
+
88
+ [X/Twitter](https://x.com/knitpkg) - [GitHub](https://github.com/knitpkg-dev/knitpkg-mt.git) - [Join Discord](https://discord.gg/bWvWpjw5m4) - [contact@knitpkg.dev](mailto:contact@knitpkg.dev)
89
+
90
+ MIT Licensed — Forever free for the community
91
+
92
+ **KnitPkg – The future of MQL5 development.**
93
+
94
+ ---
95
+
96
+ **DISCLAIMER:**
97
+ THE SOFTWARE IS PROVIDED **"AS IS"**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
98
+
@@ -0,0 +1,104 @@
1
+ # knitpkg/cli.py
2
+ """
3
+ Main CLI entry point for KnitPkg for MetaTrader.
4
+
5
+ Automatically loads all commands from knitpkg.commands and extensions.
6
+ """
7
+
8
+ import importlib
9
+ import pkgutil
10
+ from types import ModuleType
11
+
12
+ import typer
13
+ from rich.console import Console
14
+
15
+ from knitpkg.core.cli_version import get_package_version
16
+
17
+
18
+ app = typer.Typer(
19
+ name="KnitPkg for MetaTrader",
20
+ help="KnitPkg for MetaTrader - Professional package manager for MQL5/MQL4",
21
+ add_completion=False,
22
+ no_args_is_help=True,
23
+ )
24
+
25
+ loaded_commands = set()
26
+
27
+ # -------------------------------------------------------------------
28
+ # Dynamic command loading utilities
29
+ # -------------------------------------------------------------------
30
+ def _load_commands_from_package(package_name: str) -> None:
31
+ """
32
+ Import all submodules from a package and call register(app) on each module that defines it.
33
+ """
34
+ try:
35
+ pkg = importlib.import_module(package_name)
36
+ except ImportError:
37
+ return
38
+
39
+ # Register the package itself if it has a register function
40
+ _register_if_available(pkg)
41
+
42
+ # Register all submodules
43
+ for finder, mod_name, is_pkg in pkgutil.iter_modules(pkg.__path__, pkg.__name__ + "."):
44
+ if mod_name in loaded_commands:
45
+ continue
46
+ try:
47
+ mod = importlib.import_module(mod_name)
48
+ except ImportError:
49
+ continue
50
+ _register_if_available(mod)
51
+ loaded_commands.add(mod_name)
52
+
53
+
54
+ def _register_if_available(mod: ModuleType) -> None:
55
+ """
56
+ Call register(app) on the module if the function exists.
57
+ """
58
+ register_func = getattr(mod, "register", None)
59
+ if callable(register_func):
60
+ register_func(app)
61
+
62
+
63
+ # -------------------------------------------------------------------
64
+ # Load optional PRO commands
65
+ # -------------------------------------------------------------------
66
+ _load_commands_from_package("knitpkg.commands.pro")
67
+
68
+ # -------------------------------------------------------------------
69
+ # Load standard commands
70
+ # -------------------------------------------------------------------
71
+ _load_commands_from_package("knitpkg.commands")
72
+
73
+ # -------------------------------------------------------------------
74
+ # Main callback (version)
75
+ # -------------------------------------------------------------------
76
+ @app.callback()
77
+ def main(
78
+ version: bool = typer.Option(
79
+ False,
80
+ "--version",
81
+ "-v",
82
+ help="Show the version of KnitPkg for MetaTrader and exit.",
83
+ callback=lambda value: _version_callback(value),
84
+ is_eager=True,
85
+ )
86
+ ):
87
+ """
88
+ KnitPkg for MetaTrader CLI.
89
+ """
90
+ pass
91
+
92
+
93
+ def _version_callback(value: bool):
94
+ if value:
95
+ console = Console(log_path=False)
96
+ current_version = get_package_version()
97
+ console.print(
98
+ f"[bold green]KnitPkg for MetaTrader[/] version [cyan]{current_version}[/]"
99
+ )
100
+ raise typer.Exit()
101
+
102
+
103
+ if __name__ == "__main__":
104
+ app()
@@ -0,0 +1,93 @@
1
+ from typing import Optional
2
+ from pathlib import Path
3
+ import typer
4
+ from rich.console import Console
5
+
6
+ from knitpkg.core.registry import Registry
7
+ from knitpkg.core.global_config import get_registry_url
8
+ from knitpkg.core.project_manager import ProjectManager
9
+ from knitpkg.core.exceptions import KnitPkgError, RegistryError
10
+
11
+ # ==============================================================
12
+ # COMMAND WRAPPER
13
+ # ==============================================================
14
+
15
+ def add_command(project_name: str, verspec: Optional[str], project_dir: Path, console: Console, verbose: bool):
16
+ """Command wrapper for add command."""
17
+
18
+ project_path = Path(project_dir).resolve()
19
+
20
+ registry_url = get_registry_url()
21
+ registry: Registry = Registry(registry_url, console=console, verbose=verbose)
22
+
23
+ project_manager: ProjectManager = ProjectManager(project_path, registry, console, True if verbose else False)
24
+ project_manager.add_dependency(project_name, verspec)
25
+
26
+
27
+ def register(app):
28
+ """Register the add command with the main Typer app."""
29
+
30
+ @app.command()
31
+ def add(
32
+ project_name: str = typer.Argument(
33
+ ...,
34
+ help="Name of the project to add as a dependency"
35
+ ),
36
+ verspec: Optional[str] = typer.Option(
37
+ '*',
38
+ "--verspec",
39
+ "-v",
40
+ help="Version specifier for the dependency"
41
+ ),
42
+ project_dir: Optional[Path] = typer.Option(
43
+ None,
44
+ "--project-dir",
45
+ "-d",
46
+ help="Project directory (default: current directory)"
47
+ ),
48
+ verbose: Optional[bool] = typer.Option(
49
+ False,
50
+ "--verbose",
51
+ help="Show detailed output"
52
+ )
53
+ ):
54
+ """Add a dependency to the current project."""
55
+
56
+ console: Console = Console(log_path=False)
57
+
58
+ from knitpkg.core.console import ConsoleAware
59
+ console_awr = ConsoleAware(console=console, verbose=True if verbose else False)
60
+
61
+ try:
62
+ console_awr.print("")
63
+ project_dir = project_dir if project_dir is not None else Path.cwd()
64
+ add_command(project_name, verspec, project_dir,
65
+ console=console,
66
+ verbose=True if verbose else False)
67
+ from knitpkg.core.telemetry import print_telemetry_warning
68
+ print_telemetry_warning(project_dir)
69
+ console_awr.print("")
70
+
71
+ except KeyboardInterrupt:
72
+ console_awr.print("\n[bold yellow]⚠️ Add cancelled by user.[/bold yellow]")
73
+ console_awr.print("")
74
+ raise typer.Exit(code=1)
75
+
76
+ except RegistryError as e:
77
+ console_awr.print(f"\n[bold red]❌ Registry error:[/bold red] {e}. Reason: {e.reason} ")
78
+ if verbose:
79
+ console_awr.log(f" Status Code: {e.status_code}")
80
+ console_awr.log(f" Error type: {e.error_type}")
81
+ console_awr.log(f" Request URL: {e.request_url}")
82
+ console_awr.print("")
83
+ raise typer.Exit(code=1)
84
+
85
+ except KnitPkgError as e:
86
+ console_awr.print(f"\n[bold red]❌ Add failed:[/bold red] {e}")
87
+ console_awr.print("")
88
+ raise typer.Exit(code=1)
89
+
90
+ except Exception as e:
91
+ console_awr.print(f"\n[bold red]❌ Unexpected error:[/bold red] {e}")
92
+ console_awr.print("")
93
+ raise typer.Exit(code=1)
@@ -0,0 +1,87 @@
1
+ # knitpkg/commands/autocomplete.py
2
+
3
+ """
4
+ KnitPkg for MetaTrader autocomplete command — generates autocomplete files.
5
+
6
+ This module handles the generation of MQL include files that provide
7
+ autocomplete functionality for KnitPkg-managed packages within MetaEditor.
8
+ """
9
+ from pathlib import Path
10
+ from typing import Optional
11
+ import typer
12
+ from rich.console import Console
13
+
14
+ from knitpkg.mql.autocomplete import AutocompleteTools
15
+ from knitpkg.core.exceptions import KnitPkgError, RegistryError
16
+
17
+ # ==============================================================
18
+ # COMMAND WRAPPER
19
+ # ==============================================================
20
+
21
+ def autocomplete_command(project_dir: Path, console: Console, verbose: bool):
22
+ """Command wrapper"""
23
+ generator = AutocompleteTools(project_dir, console, verbose)
24
+ generator.generate_autocomplete()
25
+
26
+ # ==============================================================
27
+ # CLI REGISTRATION
28
+ # ==============================================================
29
+
30
+ def register(app):
31
+ """Register the autocomplete command with the Typer app."""
32
+
33
+ @app.command()
34
+ def autocomplete(
35
+ project_dir: Optional[Path] = typer.Option(
36
+ None,
37
+ "--project-dir",
38
+ "-d",
39
+ help="Project directory (default: current directory)"
40
+ ),
41
+ verbose: Optional[bool] = typer.Option(
42
+ False,
43
+ "--verbose",
44
+ help="Show detailed output"
45
+ )
46
+ ):
47
+ """Generate autocomplete.mqh for MetaEditor for package development."""
48
+ if project_dir is None:
49
+ project_dir = Path.cwd()
50
+ else:
51
+ project_dir = Path(project_dir).resolve()
52
+
53
+ console = Console(log_path=False)
54
+
55
+ from knitpkg.core.console import ConsoleAware
56
+ console_awr = ConsoleAware(console=console, verbose=True if verbose else False)
57
+
58
+ try:
59
+ console_awr.print("")
60
+ autocomplete_command(project_dir, console, True if verbose else False)
61
+ from knitpkg.core.telemetry import print_telemetry_warning
62
+ print_telemetry_warning(project_dir)
63
+ console_awr.print("")
64
+
65
+ except KeyboardInterrupt:
66
+ console_awr.print("\n[bold yellow]⚠️ Autocomplete generation cancelled by user.[/bold yellow]")
67
+ console_awr.print("")
68
+ raise typer.Exit(code=1)
69
+
70
+ except RegistryError as e:
71
+ console_awr.print(f"\n[bold red]❌ Registry error:[/bold red] {e}. Reason: {e.reason} ")
72
+ if verbose:
73
+ console_awr.log(f" Status Code: {e.status_code}")
74
+ console_awr.log(f" Error type: {e.error_type}")
75
+ console_awr.log(f" Request URL: {e.request_url}")
76
+ console_awr.print("")
77
+ raise typer.Exit(code=1)
78
+
79
+ except KnitPkgError as e:
80
+ console_awr.print(f"\n[bold red]❌ Autocomplete generation failed:[/bold red] {e}")
81
+ console_awr.print("")
82
+ raise typer.Exit(code=1)
83
+
84
+ except Exception as e:
85
+ console_awr.print(f"\n[bold red]❌ Unexpected error:[/bold red] {e}")
86
+ console_awr.print("")
87
+ raise typer.Exit(code=1)