nucli 0.2.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.
nucli-0.2.0/.gitignore ADDED
@@ -0,0 +1,208 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ share/python-wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .nox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *.cover
48
+ *.py,cover
49
+ .hypothesis/
50
+ .pytest_cache/
51
+ cover/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+ db.sqlite3-journal
62
+
63
+ # Flask stuff:
64
+ instance/
65
+ .webassets-cache
66
+
67
+ # Scrapy stuff:
68
+ .scrapy
69
+
70
+ # PyBuilder
71
+ .pybuilder/
72
+ target/
73
+
74
+ # Jupyter Notebook
75
+ .ipynb_checkpoints
76
+
77
+ # IPython
78
+ profile_default/
79
+ ipython_config.py
80
+
81
+ # pyenv
82
+ # For a library or package, you might want to ignore these files since the code is
83
+ # intended to run in multiple environments; otherwise, check them in:
84
+ # .python-version
85
+
86
+ # pipenv
87
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
89
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
90
+ # install all needed dependencies.
91
+ #Pipfile.lock
92
+
93
+ # poetry
94
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
95
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
96
+ # commonly ignored for libraries.
97
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
98
+ poetry.lock
99
+
100
+ # uv
101
+ uv.lock
102
+
103
+ # pdm
104
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
105
+ #pdm.lock
106
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
107
+ # in version control.
108
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
109
+ .pdm.toml
110
+ .pdm-python
111
+ .pdm-build/
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ .idea/
162
+ .vscode/
163
+
164
+ .DS_Store
165
+
166
+ # Testing
167
+ .pytest_cache/
168
+ .coverage
169
+ htmlcov/
170
+ tests/reports/
171
+
172
+ # Profiling
173
+ *.prof
174
+ *.lprof
175
+
176
+ # Benchmarking
177
+ benchmark_results/
178
+ *.benchmark
179
+ *.benchmarks
180
+
181
+ # Cython
182
+ *.c
183
+ *.html
184
+
185
+ # Ruff
186
+ .ruff_cache/
187
+
188
+ # Misc
189
+ /*playground
190
+ .db*/
191
+ .state*/
192
+ .logs*/
193
+
194
+ # cython files
195
+ *.c
196
+ *.cpp
197
+ *.dylib
198
+ *.so
199
+ lib*.so.*
200
+
201
+ # syncthing
202
+ .stfolder
203
+
204
+ # nudle UI (vite / node)
205
+ node_modules/
206
+ !packages/nustd/src/nu/ui/web/nudle/dist/
207
+ packages/nustd/src/nu/ui/web/nudle/dist/*
208
+ !packages/nustd/src/nu/ui/web/nudle/dist/.gitkeep
nucli-0.2.0/LICENSE.md ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Gor Arakelyan
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
nucli-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.5
2
+ Name: nucli
3
+ Version: 0.2.0
4
+ Summary: The `nu` command line: doctor, demos, telemetry. Ships alongside the nucore kernel and the nustd fabrics.
5
+ Project-URL: Repository, https://github.com/nustackdev/nu
6
+ Author-email: Gor Arakelyan <gorarkln@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE.md
9
+ Keywords: agentic,ai-agents,cli,database,distributed-systems,key-value-store,llm,nu,nustack,observability,python,ray,real-time,rocksdb,state-management,ui
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: click>=8.0
19
+ Requires-Dist: nustd>=0.2.0
20
+ Requires-Dist: rich-click>=1.6
21
+ Requires-Dist: rich>=10.7
22
+ Description-Content-Type: text/markdown
23
+
24
+ # nucli
25
+
26
+ The `nu` command line for [Nu](https://nustack.dev).
27
+
28
+ Installing this gives you the `nu` executable:
29
+
30
+ ```bash
31
+ nu --version
32
+ nu doctor # environment + fabric backend check
33
+ nu demo movies # run a packaged demo app
34
+ nu telemetry # see / change telemetry settings
35
+ ```
36
+
37
+ It ships `nu._cli` into the `nu.` namespace and depends on
38
+ [`nustd`](https://pypi.org/project/nustd/) (which pulls the
39
+ [`nucore`](https://pypi.org/project/nucore/) kernel) because the
40
+ packaged demos run on `nu.ui` and `nu.kv` at runtime.
41
+
42
+ You normally do not install this directly - `pip install "nustd[all]" nucli`
43
+ brings it along. Released in lockstep with the kernel. Docs at
44
+ [nustack.dev](https://nustack.dev).
nucli-0.2.0/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # nucli
2
+
3
+ The `nu` command line for [Nu](https://nustack.dev).
4
+
5
+ Installing this gives you the `nu` executable:
6
+
7
+ ```bash
8
+ nu --version
9
+ nu doctor # environment + fabric backend check
10
+ nu demo movies # run a packaged demo app
11
+ nu telemetry # see / change telemetry settings
12
+ ```
13
+
14
+ It ships `nu._cli` into the `nu.` namespace and depends on
15
+ [`nustd`](https://pypi.org/project/nustd/) (which pulls the
16
+ [`nucore`](https://pypi.org/project/nucore/) kernel) because the
17
+ packaged demos run on `nu.ui` and `nu.kv` at runtime.
18
+
19
+ You normally do not install this directly - `pip install "nustd[all]" nucli`
20
+ brings it along. Released in lockstep with the kernel. Docs at
21
+ [nustack.dev](https://nustack.dev).
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "nucli"
7
+ version = "0.2.0"
8
+ description = "The `nu` command line: doctor, demos, telemetry. Ships alongside the nucore kernel and the nustd fabrics."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ authors = [{ name = "Gor Arakelyan", email = "gorarkln@gmail.com" }]
12
+ requires-python = ">=3.10"
13
+ # Released in lockstep with the kernel. Carries no `nu/__init__.py` -- it drops
14
+ # `nu._cli` into the `nu.` namespace the kernel owns. Depends on `nustd` rather
15
+ # than the bare kernel because the packaged demos (`nu demo movies`) run on
16
+ # `nu.ui` and `nu.kv` at runtime.
17
+ dependencies = [
18
+ "nustd>=0.2.0",
19
+ "click>=8.0",
20
+ "rich>=10.7",
21
+ "rich-click>=1.6",
22
+ ]
23
+ keywords = [
24
+ "nu",
25
+ "nustack",
26
+ "python",
27
+ "cli",
28
+ "state-management",
29
+ "distributed-systems",
30
+ "ai-agents",
31
+ "agentic",
32
+ "ray",
33
+ "llm",
34
+ "database",
35
+ "key-value-store",
36
+ "rocksdb",
37
+ "ui",
38
+ "real-time",
39
+ "observability",
40
+ ]
41
+ classifiers = [
42
+ "Development Status :: 3 - Alpha",
43
+ "License :: OSI Approved :: Apache Software License",
44
+ "Programming Language :: Python :: 3",
45
+ "Programming Language :: Python :: 3.10",
46
+ "Programming Language :: Python :: 3.11",
47
+ "Programming Language :: Python :: 3.12",
48
+ "Programming Language :: Python :: 3.13",
49
+ ]
50
+
51
+ [project.urls]
52
+ Repository = "https://github.com/nustackdev/nu"
53
+
54
+ [project.scripts]
55
+ nu = "nu._cli:main"
56
+
57
+ [tool.hatch.build.targets.wheel]
58
+ packages = ["src/nu"]
59
+ # No `nu/__init__.py` here on purpose: the kernel wheel owns the package root
60
+ # and the installs merge into one `site-packages/nu/`.
@@ -0,0 +1,6 @@
1
+ """The `nu` command — entrypoint package."""
2
+
3
+ from nu._cli.main import cli, main
4
+
5
+
6
+ __all__ = ["cli", "main"]
@@ -0,0 +1,7 @@
1
+ """Enables `python -m nu._cli`."""
2
+
3
+ from nu._cli.main import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ main()
@@ -0,0 +1,26 @@
1
+ """Shared helpers for CLI commands."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.resources as resources
6
+ from importlib.metadata import PackageNotFoundError, version
7
+ from pathlib import Path
8
+
9
+
10
+ def nu_version() -> str:
11
+ try:
12
+ return version("nucore")
13
+ except PackageNotFoundError:
14
+ return "0.0.0+dev"
15
+
16
+
17
+ def demos_root() -> Path:
18
+ """Locate packaged demo scripts (ships as nu._cli.demos)."""
19
+ return Path(str(resources.files("nu._cli").joinpath("demos")))
20
+
21
+
22
+ def demos() -> dict[str, Path]:
23
+ root = demos_root()
24
+ if not root.is_dir():
25
+ return {}
26
+ return {p.stem: p for p in sorted(root.glob("*.py")) if not p.stem.startswith("_")}
@@ -0,0 +1 @@
1
+ """Individual click commands wired into the `nu` group."""
@@ -0,0 +1,72 @@
1
+ """`nu demo` — list bundled demos, or run one by name."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import ast
6
+ import runpy
7
+ import sys
8
+ from typing import TYPE_CHECKING
9
+
10
+ import rich_click as click
11
+ from rich.console import Console
12
+ from rich.table import Table
13
+ from rich.text import Text
14
+
15
+ from nu._cli._meta import demos
16
+ from nu._config.branding import BLUE, PURPLE
17
+
18
+
19
+ if TYPE_CHECKING:
20
+ from pathlib import Path
21
+
22
+
23
+ _console = Console()
24
+
25
+
26
+ def _description(path: Path) -> str:
27
+ """Return the first line of the module docstring, or empty string."""
28
+ try:
29
+ tree = ast.parse(path.read_text(), filename=str(path))
30
+ except (OSError, SyntaxError):
31
+ return ""
32
+ doc = ast.get_docstring(tree) or ""
33
+ return doc.strip().splitlines()[0] if doc else ""
34
+
35
+
36
+ def _list(found: dict[str, Path]) -> None:
37
+ if not found:
38
+ _console.print("[yellow]no demos found[/yellow]")
39
+ sys.exit(1)
40
+ table = Table(show_header=False, box=None, padding=(0, 2))
41
+ table.add_column(style=f"bold {BLUE}")
42
+ table.add_column(style="dim")
43
+ for name, path in found.items():
44
+ table.add_row(name, _description(path))
45
+ _console.print(Text("demos", style=f"bold {PURPLE}"))
46
+ _console.print(table)
47
+ _console.print(Text.assemble(("run with: ", "dim"), ("nu demo <name>", f"bold {BLUE}")))
48
+
49
+
50
+ @click.command(help="List bundled demos, or run one by name (nu demo <name>).")
51
+ @click.argument("name", required=False)
52
+ def demo(name: str | None) -> None:
53
+ """No arg -> list; name -> run that demo."""
54
+ found = demos()
55
+ if name is None:
56
+ _list(found)
57
+ return
58
+ if name not in found:
59
+ _console.print(f"[red]unknown demo:[/red] [bold]{name}[/bold]", highlight=False)
60
+ _console.print(
61
+ Text.assemble(
62
+ ("available: ", "dim"),
63
+ (", ".join(found) or "(none)", BLUE),
64
+ ),
65
+ )
66
+ sys.exit(2)
67
+ try:
68
+ runpy.run_path(str(found[name]), run_name="__main__")
69
+ except KeyboardInterrupt:
70
+ # Ctrl+C during a demo: nudle already printed its stopped banner;
71
+ # don't let click surface its default "Aborted!" line on top of it.
72
+ pass