netherframe.cli 0.2.1__tar.gz → 0.3.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 (157) hide show
  1. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/PKG-INFO +3 -5
  2. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/commands/__init__.py +30 -9
  3. netherframe_cli-0.3.0/netherframe/cli/commands/backend.py +102 -0
  4. netherframe_cli-0.3.0/netherframe/cli/commands/completion_command.py +25 -0
  5. netherframe_cli-0.3.0/netherframe/cli/commands/config_command.py +51 -0
  6. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/commands/convert.py +6 -11
  7. netherframe_cli-0.3.0/netherframe/cli/commands/discover.py +450 -0
  8. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/commands/drift.py +83 -228
  9. netherframe_cli-0.3.0/netherframe/cli/commands/encode.py +22 -0
  10. netherframe_cli-0.3.0/netherframe/cli/commands/follow_command.py +188 -0
  11. netherframe_cli-0.3.0/netherframe/cli/commands/generation.py +269 -0
  12. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/commands/graph_state.py +115 -173
  13. netherframe_cli-0.3.0/netherframe/cli/commands/hybrid.py +834 -0
  14. netherframe_cli-0.3.0/netherframe/cli/commands/infrastructure.py +548 -0
  15. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/commands/lint.py +9 -21
  16. netherframe_cli-0.3.0/netherframe/cli/commands/providers.py +122 -0
  17. netherframe_cli-0.3.0/netherframe/cli/commands/skill.py +63 -0
  18. netherframe_cli-0.3.0/netherframe/cli/commands/synthesis.py +157 -0
  19. netherframe_cli-0.3.0/netherframe/cli/commands/tui_command.py +70 -0
  20. netherframe_cli-0.3.0/netherframe/cli/commands/vars_command.py +72 -0
  21. netherframe_cli-0.3.0/netherframe/cli/commands/watch_command.py +32 -0
  22. netherframe_cli-0.3.0/netherframe/cli/completion.py +275 -0
  23. netherframe_cli-0.3.0/netherframe/cli/display/__init__.py +6 -0
  24. netherframe_cli-0.3.0/netherframe/cli/display/changes.py +83 -0
  25. netherframe_cli-0.3.0/netherframe/cli/display/diffs.py +176 -0
  26. netherframe_cli-0.3.0/netherframe/cli/display/paths.py +7 -0
  27. netherframe_cli-0.3.0/netherframe/cli/display/progress.py +197 -0
  28. netherframe_cli-0.3.0/netherframe/cli/display/report.py +277 -0
  29. netherframe_cli-0.3.0/netherframe/cli/display/sensitive.py +7 -0
  30. netherframe_cli-0.3.0/netherframe/cli/errors.py +65 -0
  31. netherframe_cli-0.3.0/netherframe/cli/main.py +113 -0
  32. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/services/app_resolver.py +1 -1
  33. netherframe_cli-0.3.0/netherframe/cli/services/stack_inventory.py +65 -0
  34. netherframe_cli-0.3.0/netherframe/cli/settings_flags.py +118 -0
  35. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/skills/netherframe/SKILL.md +20 -3
  36. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/skills/netherframe/references/authoring.md +48 -2
  37. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/skills/netherframe/references/execution.md +33 -5
  38. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/skills/netherframe/references/migration.md +2 -2
  39. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/__init__.py +6 -0
  40. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/app.py +2354 -0
  41. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/documents.py +256 -0
  42. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/equivalents.py +95 -0
  43. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/external.py +94 -0
  44. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/graph.py +701 -0
  45. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/models.py +390 -0
  46. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/overview.py +181 -0
  47. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/sessions.py +1889 -0
  48. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/skin.py +536 -0
  49. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/views.py +857 -0
  50. netherframe_cli-0.3.0/netherframe/cli/tui/explorer/widgets.py +539 -0
  51. netherframe_cli-0.3.0/nf/cli/commands/completion_command.py +4 -0
  52. netherframe_cli-0.3.0/nf/cli/commands/follow_command.py +4 -0
  53. netherframe_cli-0.3.0/nf/cli/commands/tui_command.py +4 -0
  54. netherframe_cli-0.3.0/nf/cli/commands/vars_command.py +4 -0
  55. netherframe_cli-0.3.0/nf/cli/completion.py +4 -0
  56. netherframe_cli-0.3.0/nf/cli/display/__init__.py +4 -0
  57. netherframe_cli-0.3.0/nf/cli/display/changes.py +4 -0
  58. netherframe_cli-0.3.0/nf/cli/display/diffs.py +4 -0
  59. netherframe_cli-0.3.0/nf/cli/display/paths.py +4 -0
  60. netherframe_cli-0.3.0/nf/cli/display/progress.py +4 -0
  61. netherframe_cli-0.3.0/nf/cli/display/report.py +4 -0
  62. netherframe_cli-0.3.0/nf/cli/display/sensitive.py +4 -0
  63. netherframe_cli-0.3.0/nf/cli/errors.py +4 -0
  64. netherframe_cli-0.3.0/nf/cli/settings_flags.py +4 -0
  65. netherframe_cli-0.3.0/nf/cli/tui/explorer/__init__.py +4 -0
  66. netherframe_cli-0.3.0/nf/cli/tui/explorer/app.py +4 -0
  67. netherframe_cli-0.3.0/nf/cli/tui/explorer/documents.py +4 -0
  68. netherframe_cli-0.3.0/nf/cli/tui/explorer/equivalents.py +4 -0
  69. netherframe_cli-0.3.0/nf/cli/tui/explorer/external.py +4 -0
  70. netherframe_cli-0.3.0/nf/cli/tui/explorer/graph.py +4 -0
  71. netherframe_cli-0.3.0/nf/cli/tui/explorer/models.py +4 -0
  72. netherframe_cli-0.3.0/nf/cli/tui/explorer/overview.py +4 -0
  73. netherframe_cli-0.3.0/nf/cli/tui/explorer/sessions.py +4 -0
  74. netherframe_cli-0.3.0/nf/cli/tui/explorer/skin.py +4 -0
  75. netherframe_cli-0.3.0/nf/cli/tui/explorer/views.py +4 -0
  76. netherframe_cli-0.3.0/nf/cli/tui/explorer/widgets.py +4 -0
  77. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/pyproject.toml +6 -5
  78. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/pyproject.toml.orig +4 -5
  79. netherframe_cli-0.2.1/netherframe/cli/commands/backend.py +0 -305
  80. netherframe_cli-0.2.1/netherframe/cli/commands/config_command.py +0 -98
  81. netherframe_cli-0.2.1/netherframe/cli/commands/discover.py +0 -679
  82. netherframe_cli-0.2.1/netherframe/cli/commands/encode.py +0 -130
  83. netherframe_cli-0.2.1/netherframe/cli/commands/generation.py +0 -861
  84. netherframe_cli-0.2.1/netherframe/cli/commands/hybrid.py +0 -461
  85. netherframe_cli-0.2.1/netherframe/cli/commands/idiff.py +0 -493
  86. netherframe_cli-0.2.1/netherframe/cli/commands/infrastructure.py +0 -1182
  87. netherframe_cli-0.2.1/netherframe/cli/commands/init_command.py +0 -11
  88. netherframe_cli-0.2.1/netherframe/cli/commands/providers.py +0 -315
  89. netherframe_cli-0.2.1/netherframe/cli/commands/shell_command.py +0 -17
  90. netherframe_cli-0.2.1/netherframe/cli/commands/skill.py +0 -167
  91. netherframe_cli-0.2.1/netherframe/cli/commands/synthesis.py +0 -732
  92. netherframe_cli-0.2.1/netherframe/cli/commands/terraform_command.py +0 -17
  93. netherframe_cli-0.2.1/netherframe/cli/commands/watch_command.py +0 -117
  94. netherframe_cli-0.2.1/netherframe/cli/main.py +0 -177
  95. netherframe_cli-0.2.1/netherframe/cli/services/app_loader.py +0 -62
  96. netherframe_cli-0.2.1/netherframe/cli/services/graph_onboarding.py +0 -144
  97. netherframe_cli-0.2.1/netherframe/cli/services/legacy_cli.py +0 -51
  98. netherframe_cli-0.2.1/netherframe/cli/services/project_config.py +0 -107
  99. netherframe_cli-0.2.1/netherframe/cli/services/provider_batch.py +0 -620
  100. netherframe_cli-0.2.1/netherframe/cli/services/stack_inventory.py +0 -342
  101. netherframe_cli-0.2.1/netherframe/cli/tui/plan_filters.py +0 -200
  102. netherframe_cli-0.2.1/netherframe/cli/tui/plan_models.py +0 -51
  103. netherframe_cli-0.2.1/netherframe/cli/tui/plan_viewer.py +0 -745
  104. netherframe_cli-0.2.1/nf/cli/commands/idiff.py +0 -4
  105. netherframe_cli-0.2.1/nf/cli/commands/init_command.py +0 -4
  106. netherframe_cli-0.2.1/nf/cli/commands/shell_command.py +0 -4
  107. netherframe_cli-0.2.1/nf/cli/commands/terraform_command.py +0 -4
  108. netherframe_cli-0.2.1/nf/cli/services/app_loader.py +0 -4
  109. netherframe_cli-0.2.1/nf/cli/services/graph_onboarding.py +0 -4
  110. netherframe_cli-0.2.1/nf/cli/services/legacy_cli.py +0 -4
  111. netherframe_cli-0.2.1/nf/cli/services/project_config.py +0 -4
  112. netherframe_cli-0.2.1/nf/cli/services/provider_batch.py +0 -4
  113. netherframe_cli-0.2.1/nf/cli/tui/plan_filters.py +0 -4
  114. netherframe_cli-0.2.1/nf/cli/tui/plan_models.py +0 -4
  115. netherframe_cli-0.2.1/nf/cli/tui/plan_viewer.py +0 -4
  116. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/LICENSE +0 -0
  117. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/README.md +0 -0
  118. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/__init__.py +0 -0
  119. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/__main__.py +0 -0
  120. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/entrypoint.py +0 -0
  121. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/logging.py +0 -0
  122. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/options.py +0 -0
  123. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/py.typed +0 -0
  124. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/services/__init__.py +0 -0
  125. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/skills/netherframe/agents/openai.yaml +0 -0
  126. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/state_migration.py +0 -0
  127. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/tui/__init__.py +0 -0
  128. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/netherframe/cli/ui.py +0 -0
  129. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/__init__.py +0 -0
  130. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/__main__.py +0 -0
  131. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/__init__.py +0 -0
  132. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/backend.py +0 -0
  133. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/config_command.py +0 -0
  134. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/convert.py +0 -0
  135. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/discover.py +0 -0
  136. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/drift.py +0 -0
  137. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/encode.py +0 -0
  138. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/generation.py +0 -0
  139. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/graph_state.py +0 -0
  140. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/hybrid.py +0 -0
  141. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/infrastructure.py +0 -0
  142. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/lint.py +0 -0
  143. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/providers.py +0 -0
  144. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/skill.py +0 -0
  145. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/synthesis.py +0 -0
  146. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/commands/watch_command.py +0 -0
  147. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/entrypoint.py +0 -0
  148. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/logging.py +0 -0
  149. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/main.py +0 -0
  150. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/options.py +0 -0
  151. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/py.typed +0 -0
  152. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/services/__init__.py +0 -0
  153. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/services/app_resolver.py +0 -0
  154. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/services/stack_inventory.py +0 -0
  155. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/state_migration.py +0 -0
  156. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/tui/__init__.py +0 -0
  157. {netherframe_cli-0.2.1 → netherframe_cli-0.3.0}/nf/cli/ui.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netherframe.cli
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: Netherframe CLI - Command-line interface for Netherframe
5
5
  Author: Sourabh Cheedella
6
6
  Author-email: Sourabh Cheedella <cheedella.sourabh@gmail.com>
@@ -12,17 +12,15 @@ Classifier: Programming Language :: Python :: 3.14
12
12
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
13
  Classifier: Topic :: System :: Systems Administration
14
14
  Classifier: Environment :: Console
15
- Requires-Dist: netherframe-core>=0.9.0
15
+ Requires-Dist: netherframe-core>=0.10.0
16
+ Requires-Dist: netherframe-sdk>=0.1.0
16
17
  Requires-Dist: netherframe-generation>=0.3.0
17
18
  Requires-Dist: netherframe-legacy-functions-hashicorp-terraform
18
19
  Requires-Dist: click>=8.5.1
19
20
  Requires-Dist: rich>=15.0.0
20
21
  Requires-Dist: textual>=8.2.8
21
22
  Requires-Dist: questionary>=2.1.1
22
- Requires-Dist: watchdog>=7.1.0
23
23
  Requires-Dist: pyyaml>=6.0.3
24
- Requires-Dist: tomli-w>=1.2.0
25
- Requires-Dist: urllib3>=2.8.0
26
24
  Requires-Dist: pytest>=9.2.0 ; extra == 'dev'
27
25
  Requires-Dist: pytest-mock>=3.17.0 ; extra == 'dev'
28
26
  Requires-Python: >=3.14
@@ -12,6 +12,8 @@ from typing import NamedTuple
12
12
 
13
13
  import click
14
14
 
15
+ from netherframe.cli.errors import NfGroup
16
+
15
17
 
16
18
  class LazyCommand(NamedTuple):
17
19
  module: str
@@ -33,21 +35,18 @@ LAZY_COMMANDS: dict[str, LazyCommand] = {
33
35
  "apply": LazyCommand("netherframe.cli.commands.infrastructure", "apply", "Build or change infrastructure for a stack or app."),
34
36
  "destroy": LazyCommand("netherframe.cli.commands.infrastructure", "destroy", "Destroy infrastructure for a stack or app."),
35
37
  "diff": LazyCommand("netherframe.cli.commands.infrastructure", "diff", "Show a diff of planned changes (formatted plan)."),
36
- "idiff": LazyCommand("netherframe.cli.commands.idiff", "idiff", "View infrastructure plans in an interactive TUI"),
38
+ "tui": LazyCommand("netherframe.cli.commands.tui_command", "tui", "Browse, plan, apply and destroy apps in a terminal UI."),
39
+ "vars": LazyCommand("netherframe.cli.commands.vars_command", "vars_", "List the inputs each app takes (++name=value), and the values it would be built with."),
40
+ "follow": LazyCommand("netherframe.cli.commands.follow_command", "follow", "Follow an apply or destroy running elsewhere, as nf apply shows its own."),
37
41
  "output": LazyCommand("netherframe.cli.commands.infrastructure", "output", "Show output values from a stack."),
38
42
  "state": LazyCommand("netherframe.cli.commands.infrastructure", "state", "Advanced state management for a stack."),
39
43
  "show": LazyCommand("netherframe.cli.commands.infrastructure", "show", "Show the current state or a saved plan for a stack."),
40
44
  "import": LazyCommand("netherframe.cli.commands.infrastructure", "import_cmd", "Import existing infrastructure into a stack."),
41
- "list-apps": LazyCommand("netherframe.cli.commands.infrastructure", "list_apps", "List configured legacy and hybrid apps."),
42
- "list-stacks": LazyCommand("netherframe.cli.commands.infrastructure", "list_stacks", "List all available stacks."),
43
- "shell": LazyCommand("netherframe.cli.commands.shell_command", "shell", "Start an interactive shell with NF context."),
44
- "cd": LazyCommand("netherframe.cli.commands.shell_command", "cd", "Change directory to stack location."),
45
+ "list": LazyCommand("netherframe.cli.commands.infrastructure", "list_", "List the project's apps or its synthesized stacks."),
45
46
  "convert": LazyCommand("netherframe.cli.commands.convert", "convert", "Convert a Terraform module into Netherframe Python."),
46
47
  "encode": LazyCommand("netherframe.cli.commands.encode", "encode", "Add the nf_autoid coding cookie to files, directories, or glob matches."),
47
48
  "config": LazyCommand("netherframe.cli.commands.config_command", "config", "Manage NF configuration."),
48
- "init-project": LazyCommand("netherframe.cli.commands.init_command", "init", "Initialize a new NF project."),
49
- "terraform": LazyCommand("netherframe.cli.commands.terraform_command", "terraform", "Run raw Terraform commands."),
50
- "console": LazyCommand("netherframe.cli.commands.terraform_command", "console", "Start Terraform console."),
49
+ "completion": LazyCommand("netherframe.cli.commands.completion_command", "completion", "Print the script that completes nf in SHELL: commands, options, settings and app inputs."),
51
50
  "backend": LazyCommand("netherframe.cli.commands.backend", "backend", "Manage backend infrastructure for state storage."),
52
51
  "drift": LazyCommand("netherframe.cli.commands.drift", "drift", "Drift detection and correction commands."),
53
52
  }
@@ -63,7 +62,7 @@ def load_lazy_command(name: str) -> click.Command:
63
62
  return command
64
63
 
65
64
 
66
- class LazyGroup(click.Group):
65
+ class LazyGroup(NfGroup):
67
66
  """A click group whose LAZY_COMMANDS are imported on first use."""
68
67
 
69
68
  def list_commands(self, ctx: click.Context) -> list[str]:
@@ -76,6 +75,28 @@ class LazyGroup(click.Group):
76
75
  self.add_command(command, cmd_name)
77
76
  return command
78
77
 
78
+ def format_options(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
79
+ """The options, then each group of settings (``netherframe.cli.settings_flags``), then the commands."""
80
+ from netherframe.cli.settings_flags import SettingOption
81
+
82
+ plain: list[tuple[str, str]] = []
83
+ groups: dict[str, list[tuple[str, str]]] = {}
84
+ for param in self.get_params(ctx):
85
+ record = param.get_help_record(ctx)
86
+ if record is None:
87
+ continue
88
+ if isinstance(param, SettingOption) and param.group:
89
+ groups.setdefault(param.group, []).append(record)
90
+ else:
91
+ plain.append(record)
92
+ if plain:
93
+ with formatter.section("Options"):
94
+ formatter.write_dl(plain)
95
+ for group, records in groups.items():
96
+ with formatter.section(f"Settings: {group}"):
97
+ formatter.write_dl(records)
98
+ self.format_commands(ctx, formatter)
99
+
79
100
  def format_commands(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
80
101
  rows: list[tuple[str, str]] = []
81
102
  limit = formatter.width - 6 - max((len(name) for name in self.list_commands(ctx)), default=0)
@@ -0,0 +1,102 @@
1
+ """nf backend: show, bootstrap and validate the state backend the settings choose (``Project.backend`` of the API)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import click
6
+ from netherframe.cli.errors import NfGroup
7
+ from netherframe.cli.settings_flags import setting
8
+ from netherframe.cli.ui import console
9
+ from netherframe.core.backends.backend_chain_models import BackendBootstrapAction
10
+ from netherframe.sdk import Project
11
+ from rich.table import Table
12
+
13
+ #: The settings of the backend, and the value of each in a BackendConfig
14
+ _SETTINGS = (
15
+ ("backend_type", lambda config: config.backend_type),
16
+ ("backend_s3_bucket", lambda config: config.config.get("bucket")),
17
+ ("backend_s3_key_prefix", lambda config: config.key_prefix),
18
+ ("backend_s3_region", lambda config: config.config.get("region")),
19
+ ("backend_s3_profile", lambda config: config.config.get("profile")),
20
+ ("backend_local_path", lambda config: config.config.get("path")),
21
+ )
22
+
23
+
24
+ def _flag(key: str) -> str:
25
+ from netherframe.sdk.settings import SETTINGS
26
+
27
+ return next((item.flag.split("/")[0] for item in SETTINGS if item.key == key), key)
28
+
29
+
30
+ @click.group(cls=NfGroup)
31
+ def backend() -> None:
32
+ """Manage backend infrastructure for state storage."""
33
+
34
+
35
+ @backend.command()
36
+ @click.option("--force/--no-force", default=False, help="Force creation even if resources exist")
37
+ @click.option("--dry-run/--no-dry-run", default=False, help="Show what would be created without actually creating")
38
+ @click.option("--tag", "tags", multiple=True, metavar="KEY=VALUE", help="Tag the resources created; repeat for more")
39
+ @setting("bootstrap_aws_provider_version", "--aws-provider-version", metavar="VERSION", help="hashicorp/aws version to bootstrap S3 with (default: the newest cached, else the latest)")
40
+ def bootstrap(force: bool, dry_run: bool, tags: tuple[str, ...]) -> None:
41
+ """Create the resources of the state backend the settings choose (an S3 bucket and lock table)."""
42
+ console.print("[bold blue]Bootstrapping backend resources...[/bold blue]")
43
+ report = Project().backend.bootstrap(force, dry_run, tags)
44
+ label = report.backend_type
45
+ match report.action:
46
+ case BackendBootstrapAction.UNSUPPORTED:
47
+ console.print(f"[red]Bootstrap not supported for {label}: {report.reason}[/red]")
48
+ case BackendBootstrapAction.SKIPPED:
49
+ console.print(f"[yellow]Bootstrap skipped for {label}: {report.reason}[/yellow]")
50
+ case BackendBootstrapAction.ALREADY_EXISTS:
51
+ console.print(f"[green]✓ {label} backend resources already exist[/green]")
52
+ case BackendBootstrapAction.DRY_RUN:
53
+ console.print("[yellow]DRY RUN - No resources will be created[/yellow]")
54
+ console.print(f"{label}: {report.reason}")
55
+ case BackendBootstrapAction.BOOTSTRAPPED:
56
+ resource_data = report.resources.to_dict() if report.resources is not None else {}
57
+ if resource_data:
58
+ table = Table(title="Created Resources")
59
+ table.add_column("Resource", style="cyan")
60
+ table.add_column("Name/ID", style="green")
61
+ for key, value in resource_data.items():
62
+ table.add_row(key.replace("_", " ").title(), str(value))
63
+ console.print(table)
64
+ console.print(f"[green]✓ {label} backend resources bootstrapped successfully[/green]")
65
+
66
+
67
+ @backend.command()
68
+ def validate() -> None:
69
+ """Check that the resources of the state backend the settings choose exist; exit 1 when they do not."""
70
+ console.print("[bold blue]Validating backend resources...[/bold blue]")
71
+ report = Project().backend.validate()
72
+ label = report.backend_type
73
+ if report.action is BackendBootstrapAction.UNSUPPORTED:
74
+ console.print(f"[yellow]Validation not implemented for {label}: {report.reason}[/yellow]")
75
+ elif report.valid:
76
+ console.print(f"[green]✓ {label} backend resources are valid and accessible[/green]")
77
+ else:
78
+ console.print("[red]✗ Backend validation failed[/red]")
79
+ console.print(f"{label}: {report.reason}")
80
+ console.print("Run 'nf backend bootstrap' to create missing resources")
81
+ raise click.exceptions.Exit(1)
82
+
83
+
84
+ @backend.command()
85
+ def show() -> None:
86
+ """Show the state backend the settings choose, and where states go with it."""
87
+ configured = Project().backend.show()
88
+ config = configured.config
89
+ table = Table(title="State Backend")
90
+ table.add_column("Setting", style="cyan")
91
+ table.add_column("Value", style="green")
92
+ table.add_column("From", style="dim")
93
+ for key, value_of in _SETTINGS:
94
+ value = value_of(config)
95
+ if value is None:
96
+ continue
97
+ source = config.sources.get(key)
98
+ table.add_row(key, str(value), "default" if source is None else _flag(key) if source == "flag" else source)
99
+ console.print(table)
100
+ console.print(f"Hybrid apps' state: {configured.hybrid_state or f'[yellow]{configured.hybrid_problem}[/yellow]'}")
101
+ console.print(f"Legacy stacks' state: {configured.legacy_state}")
102
+ console.print("[dim]For the apps and stacks whose code names no backend.[/dim]")
@@ -0,0 +1,25 @@
1
+ """``nf completion``: the shell script that completes nf (``Project.completion`` of the API)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import click
6
+
7
+ from netherframe.cli.errors import NfCommand
8
+ from netherframe.sdk import Project
9
+
10
+
11
+ @click.command("completion", cls=NfCommand)
12
+ @click.argument("shell", type=click.Choice(["bash", "zsh", "fish"]))
13
+ def completion(shell: str) -> None:
14
+ """Print the script that completes nf in SHELL: commands, options, settings and app inputs.
15
+
16
+ Beyond commands and options, it completes the settings of nf written after the command
17
+ (nf apply --graph-lease-ttl), app inputs (++ to the inputs the app takes, ++env= to their
18
+ choices, ++@ to files) and their values. Install it once:
19
+
20
+ \b
21
+ bash nf completion bash > ~/.local/share/bash-completion/completions/nf
22
+ zsh nf completion zsh > "${fpath[1]}/_nf" (or: eval "$(nf completion zsh)" in ~/.zshrc)
23
+ fish nf completion fish > ~/.config/fish/completions/nf.fish
24
+ """
25
+ click.echo(Project().completion(shell))
@@ -0,0 +1,51 @@
1
+ """nf config: show, get and validate [tool.nf] (``Project.config`` of the API)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import click
6
+
7
+ from netherframe.cli.errors import NfGroup
8
+ from netherframe.sdk import Project
9
+
10
+
11
+ @click.group(cls=NfGroup)
12
+ def config() -> None:
13
+ """Manage NF configuration."""
14
+
15
+
16
+ @config.command()
17
+ def show() -> None:
18
+ """Show current configuration."""
19
+ config_data = Project().config.show()
20
+ if not config_data:
21
+ click.echo("No NF configuration found in pyproject.toml")
22
+ return
23
+ click.echo("[tool.nf]")
24
+ for key, value in config_data.items():
25
+ click.echo(f"{key} = {value!r}")
26
+
27
+
28
+ @config.command()
29
+ @click.argument("key")
30
+ def get(key: str) -> None:
31
+ """Get a specific configuration value."""
32
+ value = Project().config.get(key)
33
+ if isinstance(value, list):
34
+ for item in value:
35
+ click.echo(item)
36
+ else:
37
+ click.echo(value)
38
+
39
+
40
+ @config.command()
41
+ def validate() -> None:
42
+ """Validate the configuration."""
43
+ check = Project().config.validate()
44
+ if not check.configured:
45
+ click.echo("No NF configuration found")
46
+ return
47
+ for file_path in check.missing_files:
48
+ click.echo(f"Error: App file not found: {file_path}", err=True)
49
+ if not check.valid:
50
+ raise SystemExit(1)
51
+ click.echo("Configuration is valid")
@@ -1,13 +1,14 @@
1
- """``nf convert``: turn a Terraform module into Netherframe Python (see netherframe.generation.convert)."""
1
+ """``nf convert``: turn a Terraform module into Netherframe Python (``Project.convert`` of the API; see netherframe.generation.convert)."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
5
  from pathlib import Path
6
6
 
7
7
  import click
8
+ from netherframe.cli.errors import NfCommand
8
9
 
9
10
 
10
- @click.command(name="convert")
11
+ @click.command(cls=NfCommand, name="convert")
11
12
  @click.argument("module_dir", type=click.Path(exists=True, file_okay=False, path_type=Path))
12
13
  @click.option("-o", "--output", type=click.Path(file_okay=False, path_type=Path), default=Path(), show_default=True, help="Directory to write the package into.")
13
14
  @click.option("--package", help="Name of the Python package to write (default: the module directory's name).")
@@ -25,16 +26,10 @@ def convert(module_dir: Path, output: Path, package: str | None, generic: bool,
25
26
  installed generated provider packages. What it cannot convert is marked
26
27
  `# TODO(nf convert): ...` with the original HCL.
27
28
  """
28
- from netherframe.generation.convert import ConversionError, HclSyntaxError, convert_module
29
+ from netherframe.sdk import Project
29
30
 
30
- try:
31
- result = convert_module(module_dir, output, package=package, use_generated_bindings=not generic, format_code=not no_format, clean=force, fetch_modules=fetch_modules, module_cache=module_cache)
32
- except (ConversionError, HclSyntaxError) as error:
33
- raise click.ClickException(str(error)) from error
34
- text = result.report()
35
- click.echo(text, nl=False)
31
+ result = Project().convert(module_dir, output=output, package=package, generic=generic, force=force, no_format=no_format, fetch_modules=fetch_modules, module_cache=module_cache, report=report)
32
+ click.echo(result.report(), nl=False)
36
33
  click.echo(f"\nWrote {len(result.files)} files to {result.output}")
37
34
  if not no_format and not result.formatted:
38
35
  click.echo("Ruff was not available: the code is not formatted", err=True)
39
- if report is not None:
40
- report.write_text(text)