clizard 0.1.0__tar.gz → 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.
Files changed (26) hide show
  1. {clizard-0.1.0/clizard.egg-info → clizard-0.2.0}/PKG-INFO +1 -1
  2. {clizard-0.1.0 → clizard-0.2.0}/clizard/__init__.py +1 -1
  3. {clizard-0.1.0 → clizard-0.2.0}/clizard/__main__.py +1 -1
  4. {clizard-0.1.0 → clizard-0.2.0}/clizard/clizard_file.py +10 -3
  5. {clizard-0.1.0 → clizard-0.2.0}/clizard/core.py +4 -1
  6. {clizard-0.1.0 → clizard-0.2.0}/clizard/scaffold.py +17 -18
  7. {clizard-0.1.0 → clizard-0.2.0/clizard.egg-info}/PKG-INFO +1 -1
  8. {clizard-0.1.0 → clizard-0.2.0}/LICENSE +0 -0
  9. {clizard-0.1.0 → clizard-0.2.0}/MANIFEST.in +0 -0
  10. {clizard-0.1.0 → clizard-0.2.0}/README.md +0 -0
  11. {clizard-0.1.0 → clizard-0.2.0}/clizard/cli_args.py +0 -0
  12. {clizard-0.1.0 → clizard-0.2.0}/clizard/config.py +0 -0
  13. {clizard-0.1.0 → clizard-0.2.0}/clizard/discover.py +0 -0
  14. {clizard-0.1.0 → clizard-0.2.0}/clizard/examples/examples_auto_cli_release_tool.py +0 -0
  15. {clizard-0.1.0 → clizard-0.2.0}/clizard/examples/examples_llmlight_app.py +0 -0
  16. {clizard-0.1.0 → clizard-0.2.0}/clizard/examples/examples_summarizer.py +0 -0
  17. {clizard-0.1.0 → clizard-0.2.0}/clizard/examples/examples_wrap_summarizer.py +0 -0
  18. {clizard-0.1.0 → clizard-0.2.0}/clizard/git_info.py +0 -0
  19. {clizard-0.1.0 → clizard-0.2.0}/clizard/project_info.py +0 -0
  20. {clizard-0.1.0 → clizard-0.2.0}/clizard.egg-info/SOURCES.txt +0 -0
  21. {clizard-0.1.0 → clizard-0.2.0}/clizard.egg-info/dependency_links.txt +0 -0
  22. {clizard-0.1.0 → clizard-0.2.0}/clizard.egg-info/entry_points.txt +0 -0
  23. {clizard-0.1.0 → clizard-0.2.0}/clizard.egg-info/requires.txt +0 -0
  24. {clizard-0.1.0 → clizard-0.2.0}/clizard.egg-info/top_level.txt +0 -0
  25. {clizard-0.1.0 → clizard-0.2.0}/pyproject.toml +0 -0
  26. {clizard-0.1.0 → clizard-0.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clizard
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: clizard is a Python library for Reusable rich-based interactive CLI framework
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License-Expression: MIT
@@ -3,4 +3,4 @@ from .config import Config
3
3
  from .cli_args import parse_args, build_parser, auto_cli
4
4
 
5
5
  __all__ = ["GenericCLI", "Config", "parse_args", "build_parser", "auto_cli"]
6
- __version__ = "0.1.0"
6
+ __version__ = "0.2.0"
@@ -30,7 +30,7 @@ def build_cli(repo_path="."):
30
30
 
31
31
  git_info = get_git_info(repo_path)
32
32
  proj_info = get_project_info(repo_path)
33
- clz = ensure_clizard_file(repo_path)
33
+ clz = ensure_clizard_file(repo_path, create=False)
34
34
 
35
35
  app_name = clz.get("app_name") or proj_info.get("name") or git_info.get("github_repo") or "clizard"
36
36
  docs_url = clz.get("docs_url") or proj_info.get("docs_url")
@@ -36,8 +36,14 @@ def save_clizard_file(data: dict, repo_path="."):
36
36
  return path
37
37
 
38
38
 
39
- def ensure_clizard_file(repo_path=".", **overrides):
40
- """Create a .clizard file with sane defaults if one doesn't exist yet."""
39
+ def ensure_clizard_file(repo_path=".", create=True, **overrides):
40
+ """Return .clizard data, merged with sane defaults if absent.
41
+
42
+ If `create` is True (default) and no .clizard file exists yet, one is
43
+ written with the defaults. If `create` is False, the defaults are
44
+ returned without touching disk -- used by callers (e.g. the interactive
45
+ clizard CLI) that should work fine with no .clizard file present.
46
+ """
41
47
  path = Path(repo_path) / CLIZARD_FILENAME
42
48
  if path.exists():
43
49
  return load_clizard_file(repo_path)
@@ -51,5 +57,6 @@ def ensure_clizard_file(repo_path=".", **overrides):
51
57
  "updates": [],
52
58
  }
53
59
  data.update(overrides)
54
- save_clizard_file(data, repo_path)
60
+ if create:
61
+ save_clizard_file(data, repo_path)
55
62
  return data
@@ -107,6 +107,8 @@ class GenericCLI:
107
107
  @staticmethod
108
108
  def _cast_value(raw: str, current):
109
109
  """Cast a string CLI value to match the type of the existing setting."""
110
+ if raw == "":
111
+ return current
110
112
  if isinstance(current, bool):
111
113
  return raw.strip().lower() in {"1", "true", "yes", "on"}
112
114
  if isinstance(current, int) and not isinstance(current, bool):
@@ -175,7 +177,8 @@ class GenericCLI:
175
177
  label += f" [dim]choices: {choices}[/dim]"
176
178
 
177
179
  while True:
178
- raw_value = Prompt.ask(label, default=str(current))
180
+ default_str = "" if current is None else str(current)
181
+ raw_value = Prompt.ask(label, default=default_str)
179
182
  caster = info.get("type")
180
183
  if caster and current is None:
181
184
  try:
@@ -5,7 +5,7 @@ import inspect
5
5
  from pathlib import Path
6
6
 
7
7
  from .discover import find_main, settings_from_main
8
- from .clizard_file import ensure_clizard_file, save_clizard_file
8
+ from .clizard_file import load_clizard_file
9
9
  from .git_info import get_git_info
10
10
 
11
11
  TEMPLATE = '''"""Auto-generated by clizard. Wraps {entry_module}.main() with the
@@ -30,24 +30,29 @@ REPO_PATH = str(Path(__file__).parent.resolve())
30
30
  _DEFAULT_SETTINGS = {settings!r}
31
31
  _DEFAULT_ARG_META = {arg_meta!r}
32
32
  _DEFAULT_CALL_STYLE = {call_style!r}
33
+ # Matches the default tips shown by `clizard` itself (see clizard_file.py /
34
+ # __main__.py) so the menu is identical whether you're running the
35
+ # interactive `clizard` CLI or this standalone generated script.
36
+ _DEFAULT_TIPS = ["/wizard", "/run", "/settings", "/docs", "/help"]
33
37
 
34
38
 
35
39
  def build_cli():
40
+ # .clizard is optional and only supplies cosmetic overrides (app_name,
41
+ # ascii_art, accent_color, tips, updates). Settings/arg_meta/call_style
42
+ # are baked into this file directly, so clizard_main.py works standalone
43
+ # with no .clizard file required.
36
44
  clz = load_clizard_file(REPO_PATH)
37
45
 
38
- # Settings/arg_meta/call_style live in .clizard so that edits made via
39
- # `/settings` while running `clizard` interactively (or by hand-editing
40
- # .clizard) are picked up here too, without needing to re-scaffold.
41
- settings = clz.get("settings") or _DEFAULT_SETTINGS
42
- arg_meta = clz.get("arg_meta") or _DEFAULT_ARG_META
43
- call_style = clz.get("call_style") or _DEFAULT_CALL_STYLE
46
+ settings = _DEFAULT_SETTINGS
47
+ arg_meta = _DEFAULT_ARG_META
48
+ call_style = _DEFAULT_CALL_STYLE
44
49
 
45
50
  cli = GenericCLI(
46
51
  app_name=clz.get("app_name") or {app_name!r},
47
52
  ascii_art=clz.get("ascii_art"),
48
53
  accent_color=clz.get("accent_color", "#d97757"),
49
54
  settings=settings,
50
- tips=clz.get("tips"),
55
+ tips=clz.get("tips") or _DEFAULT_TIPS,
51
56
  updates=clz.get("updates"),
52
57
  )
53
58
  cli.arg_meta = arg_meta
@@ -137,16 +142,10 @@ def generate_clizard_main(repo_path=".", output_name="clizard_main.py"):
137
142
  # location -- the same one `clizard` itself uses for .clizard.
138
143
  out_path = repo_path / output_name
139
144
 
140
- # Persist the discovered settings/arg_meta/call_style into .clizard so
141
- # they're loaded at runtime by build_cli() above -- this also means
142
- # edits made via `/settings` (or by hand-editing .clizard) carry over
143
- # without needing to re-scaffold, and clizard_main.py can be regenerated
144
- # later without losing customizations made elsewhere in .clizard.
145
- clz = ensure_clizard_file(str(repo_path))
146
- clz["settings"] = settings
147
- clz["arg_meta"] = safe_arg_meta
148
- clz["call_style"] = call_style
149
- save_clizard_file(clz, str(repo_path))
145
+ # .clizard is optional and used only for a cosmetic app_name override.
146
+ # Settings/arg_meta/call_style are embedded directly in clizard_main.py
147
+ # below, so no .clizard file is required for the scaffolded script to work.
148
+ clz = load_clizard_file(str(repo_path))
150
149
 
151
150
  # __main__.py can't be imported by stem name; use the package instead.
152
151
  if entry_module == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clizard
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: clizard is a Python library for Reusable rich-based interactive CLI framework
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License-Expression: MIT
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