chatenv 0.2.2__tar.gz → 0.2.3__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 (25) hide show
  1. {chatenv-0.2.2/src/chatenv.egg-info → chatenv-0.2.3}/PKG-INFO +1 -1
  2. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/__init__.py +1 -1
  3. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/cli.py +25 -4
  4. {chatenv-0.2.2 → chatenv-0.2.3/src/chatenv.egg-info}/PKG-INFO +1 -1
  5. {chatenv-0.2.2 → chatenv-0.2.3}/tests/test_chatenv_core.py +33 -0
  6. {chatenv-0.2.2 → chatenv-0.2.3}/tests/test_version.py +1 -1
  7. {chatenv-0.2.2 → chatenv-0.2.3}/LICENSE +0 -0
  8. {chatenv-0.2.2 → chatenv-0.2.3}/README.md +0 -0
  9. {chatenv-0.2.2 → chatenv-0.2.3}/pyproject.toml +0 -0
  10. {chatenv-0.2.2 → chatenv-0.2.3}/setup.cfg +0 -0
  11. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/configs.py +0 -0
  12. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/discovery.py +0 -0
  13. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/fields.py +0 -0
  14. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/paste.py +0 -0
  15. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/paths.py +0 -0
  16. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/presets/__init__.py +0 -0
  17. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/registry.py +0 -0
  18. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/source_chain.py +0 -0
  19. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/store.py +0 -0
  20. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv/utils.py +0 -0
  21. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv.egg-info/SOURCES.txt +0 -0
  22. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv.egg-info/dependency_links.txt +0 -0
  23. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv.egg-info/entry_points.txt +0 -0
  24. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv.egg-info/requires.txt +0 -0
  25. {chatenv-0.2.2 → chatenv-0.2.3}/src/chatenv.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chatenv
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: ChatArch typed environment profile manager
5
5
  Author-email: rexwzh <1073853456@qq.com>
6
6
  License-Expression: MIT
@@ -20,4 +20,4 @@ __all__ = [
20
20
  "__version__",
21
21
  ]
22
22
 
23
- __version__ = "0.2.2"
23
+ __version__ = "0.2.3"
@@ -277,7 +277,9 @@ def _resolve_config_types_or_prompt(
277
277
  return [_select_config_interactive(action=action, configs=selectable)]
278
278
 
279
279
  if not config_types and allow_multi:
280
- return list(BaseEnvConfig._registry)
280
+ raise click.ClickException(
281
+ f"{action} requires --type/-t outside interactive mode.\n{_available_config_types_message()}"
282
+ )
281
283
  if not config_types:
282
284
  raise click.ClickException(
283
285
  f"{action} requires --type/-t outside interactive mode.\n{_available_config_types_message()}"
@@ -377,6 +379,23 @@ def init_env(ctx: click.Context, config_types: tuple[str, ...], interactive: boo
377
379
  click.echo(f"Configuration saved to {_envs_dir(ctx)}")
378
380
 
379
381
 
382
+ def _has_configured_values(config_cls: type[BaseEnvConfig], values: dict[str, str]) -> bool:
383
+ """Return true when a profile has values beyond blanks and schema defaults."""
384
+ fields_by_key = {field.env_key: field for field in config_cls.get_fields().values()}
385
+ for key, value in values.items():
386
+ field = fields_by_key.get(key)
387
+ if field is None:
388
+ if value:
389
+ return True
390
+ continue
391
+ if value == "":
392
+ continue
393
+ if field.default is not None and str(field.default) == str(value):
394
+ continue
395
+ return True
396
+ return False
397
+
398
+
380
399
  @cli.command(name="list")
381
400
  @click.option("--type", "config_types", "-t", multiple=True, help="Filter config types.")
382
401
  @click.pass_context
@@ -390,12 +409,14 @@ def list_env(ctx: click.Context, config_types: tuple[str, ...]):
390
409
  found = False
391
410
  for config_cls in configs:
392
411
  profiles = store.list_profiles(config_cls)
393
- has_default = store.active_path(config_cls).exists()
394
- if not has_default and not profiles:
412
+ active_path = store.active_path(config_cls)
413
+ has_default = active_path.exists()
414
+ show_default = has_default and _has_configured_values(config_cls, store.load_active(config_cls))
415
+ if not show_default and not profiles:
395
416
  continue
396
417
  found = True
397
418
  click.echo(f"[{config_cls.get_storage_name()}]")
398
- if has_default:
419
+ if show_default:
399
420
  click.echo("- .env [default]")
400
421
  for profile in profiles:
401
422
  click.echo(f"- {profile}.env")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chatenv
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: ChatArch typed environment profile manager
5
5
  Author-email: rexwzh <1073853456@qq.com>
6
6
  License-Expression: MIT
@@ -210,6 +210,21 @@ def test_list_keeps_named_only_profiles_without_default_marker(tmp_path):
210
210
  assert "- .env [default]" not in result.output
211
211
  assert "- work.env" in result.output
212
212
 
213
+
214
+ def test_list_hides_default_only_active_profile_by_default(tmp_path):
215
+ runner = CliRunner()
216
+ home = tmp_path / "arch"
217
+ store = EnvStore(home / "envs")
218
+ store.save_active(UnitConfig, {"UNIT_KEY": "", "UNIT_VALUE": "default"})
219
+
220
+ result = runner.invoke(cli, ["--home", str(home), "list", "--type", "unit"])
221
+
222
+ assert result.exit_code == 0, result.output
223
+ assert "No profiles found under" in result.output
224
+ assert "[Unit]" not in result.output
225
+ assert "- .env [default]" not in result.output
226
+
227
+
213
228
  def test_list_reports_no_profiles_when_active_and_named_profiles_absent(tmp_path):
214
229
  runner = CliRunner()
215
230
  home = tmp_path / "arch"
@@ -530,6 +545,24 @@ def test_cli_init_with_type_still_prompts_fields_when_auto_prompt_disabled(
530
545
  assert "UNIT_VALUE='from-init'" in env_text
531
546
 
532
547
 
548
+ def test_cli_init_without_type_fails_outside_interactive_without_writing_all(
549
+ tmp_path, monkeypatch
550
+ ):
551
+ runner = CliRunner()
552
+ home = tmp_path / "arch"
553
+ monkeypatch.setenv("CHATARCH_AUTO_PROMPT", "false")
554
+ monkeypatch.setattr(
555
+ "chatenv.cli._chatstyle_resolve_interactive_mode",
556
+ _tty_resolution,
557
+ )
558
+
559
+ result = runner.invoke(cli, ["--home", str(home), "init", "-I"])
560
+
561
+ assert result.exit_code != 0
562
+ assert "init requires --type/-t outside interactive mode" in result.output
563
+ assert not (home / "envs").exists()
564
+
565
+
533
566
  def test_cli_new_prompts_for_config_type_when_type_missing(
534
567
  tmp_path, monkeypatch
535
568
  ):
@@ -4,7 +4,7 @@ from click.testing import CliRunner
4
4
 
5
5
 
6
6
  def test_version_present():
7
- assert __version__ == "0.2.2"
7
+ assert __version__ == "0.2.3"
8
8
 
9
9
 
10
10
  def test_cli_version_option():
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