rhiza 0.5.4__py3-none-any.whl → 0.5.6__py3-none-any.whl

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.
rhiza/cli.py CHANGED
@@ -12,6 +12,7 @@ from rhiza import __version__
12
12
  from rhiza.commands import init as init_cmd
13
13
  from rhiza.commands import materialize as materialize_cmd
14
14
  from rhiza.commands import validate as validate_cmd
15
+ from rhiza.commands.welcome import welcome as welcome_cmd
15
16
 
16
17
  app = typer.Typer(
17
18
  help=(
@@ -171,3 +172,17 @@ def validate(
171
172
  """
172
173
  if not validate_cmd(target):
173
174
  raise typer.Exit(code=1)
175
+
176
+
177
+ @app.command()
178
+ def welcome():
179
+ r"""Display a friendly welcome message and explain what Rhiza is.
180
+
181
+ Shows a welcome message, explains Rhiza's purpose, key features,
182
+ and provides guidance on getting started with the tool.
183
+
184
+ \b
185
+ Examples:
186
+ rhiza welcome
187
+ """
188
+ welcome_cmd()
@@ -6,6 +6,7 @@ into the target Git repository, and records managed files in
6
6
  `.rhiza.history`. Use this to take a one-shot snapshot of template files.
7
7
  """
8
8
 
9
+ import os
9
10
  import shutil
10
11
  import subprocess
11
12
  import sys
@@ -18,7 +19,7 @@ from rhiza.commands import init
18
19
  from rhiza.models import RhizaTemplate
19
20
 
20
21
 
21
- def expand_paths(base_dir: Path, paths: list[str]) -> list[Path]:
22
+ def __expand_paths(base_dir: Path, paths: list[str]) -> list[Path]:
22
23
  """Expand files/directories relative to base_dir into a flat list of files.
23
24
 
24
25
  Given a list of paths relative to ``base_dir``, return a flat list of all
@@ -40,26 +41,26 @@ def expand_paths(base_dir: Path, paths: list[str]) -> list[Path]:
40
41
  def materialize(target: Path, branch: str, target_branch: str | None, force: bool) -> None:
41
42
  """Materialize Rhiza templates into the target repository.
42
43
 
43
- This performs a sparse checkout of the template repository and copies
44
- the selected files into the target repository, recording all files
45
- under template control in `.rhiza.history`.
46
-
47
- Parameters
48
- ----------
49
- target:
50
- Path to the target repository.
51
- branch:
52
- The Rhiza template branch to use.
53
- target_branch:
54
- Optional branch name to create/checkout in target repository.
55
- force:
56
- Whether to overwrite existing files.
44
+ This performs a sparse checkout of the template repository and copies the
45
+ selected files into the target repository, recording all files under
46
+ template control in `.rhiza.history`.
47
+
48
+ Args:
49
+ target (Path): Path to the target repository.
50
+ branch (str): The Rhiza template branch to use.
51
+ target_branch (str | None): Optional branch name to create/checkout in
52
+ the target repository.
53
+ force (bool): Whether to overwrite existing files.
57
54
  """
58
55
  target = target.resolve()
59
56
 
60
57
  logger.info(f"Target repository: {target}")
61
58
  logger.info(f"Rhiza branch: {branch}")
62
59
 
60
+ # Set environment to prevent git from prompting for credentials
61
+ git_env = os.environ.copy()
62
+ git_env["GIT_TERMINAL_PROMPT"] = "0"
63
+
63
64
  # -----------------------
64
65
  # Handle target branch creation/checkout if specified
65
66
  # -----------------------
@@ -72,6 +73,7 @@ def materialize(target: Path, branch: str, target_branch: str | None, force: boo
72
73
  cwd=target,
73
74
  capture_output=True,
74
75
  text=True,
76
+ env=git_env,
75
77
  )
76
78
 
77
79
  if result.returncode == 0:
@@ -81,6 +83,7 @@ def materialize(target: Path, branch: str, target_branch: str | None, force: boo
81
83
  ["git", "checkout", target_branch],
82
84
  cwd=target,
83
85
  check=True,
86
+ env=git_env,
84
87
  )
85
88
  else:
86
89
  # Branch doesn't exist, create and checkout
@@ -89,6 +92,7 @@ def materialize(target: Path, branch: str, target_branch: str | None, force: boo
89
92
  ["git", "checkout", "-b", target_branch],
90
93
  cwd=target,
91
94
  check=True,
95
+ env=git_env,
92
96
  )
93
97
  except subprocess.CalledProcessError as e:
94
98
  logger.error(f"Failed to create/checkout branch '{target_branch}': {e}")
@@ -138,41 +142,70 @@ def materialize(target: Path, branch: str, target_branch: str | None, force: boo
138
142
  logger.info(f"Cloning {rhiza_repo}@{rhiza_branch} from {rhiza_host} into temporary directory")
139
143
 
140
144
  try:
141
- subprocess.run(
142
- [
143
- "git",
144
- "clone",
145
- "--depth",
146
- "1",
147
- "--filter=blob:none",
148
- "--sparse",
149
- "--branch",
150
- rhiza_branch,
151
- git_url,
152
- str(tmp_dir),
153
- ],
154
- check=True,
155
- stdout=subprocess.DEVNULL,
156
- )
145
+ # Clone the repository - capture output to avoid blocking
146
+ try:
147
+ subprocess.run(
148
+ [
149
+ "git",
150
+ "clone",
151
+ "--depth",
152
+ "1",
153
+ "--filter=blob:none",
154
+ "--sparse",
155
+ "--branch",
156
+ rhiza_branch,
157
+ git_url,
158
+ str(tmp_dir),
159
+ ],
160
+ check=True,
161
+ capture_output=True,
162
+ text=True,
163
+ env=git_env,
164
+ )
165
+ except subprocess.CalledProcessError as e:
166
+ logger.error(f"Failed to clone repository: {e}")
167
+ if e.stderr:
168
+ logger.error(f"Git error: {e.stderr.strip()}")
169
+ raise
157
170
 
158
- subprocess.run(
159
- ["git", "sparse-checkout", "init", "--cone"],
160
- cwd=tmp_dir,
161
- check=True,
162
- )
171
+ # Initialize sparse checkout
172
+ try:
173
+ subprocess.run(
174
+ ["git", "sparse-checkout", "init", "--cone"],
175
+ cwd=tmp_dir,
176
+ check=True,
177
+ capture_output=True,
178
+ text=True,
179
+ env=git_env,
180
+ )
181
+ except subprocess.CalledProcessError as e:
182
+ logger.error(f"Failed to initialize sparse checkout: {e}")
183
+ if e.stderr:
184
+ logger.error(f"Git error: {e.stderr.strip()}")
185
+ raise
163
186
 
164
- subprocess.run(
165
- ["git", "sparse-checkout", "set", "--skip-checks", *include_paths],
166
- cwd=tmp_dir,
167
- check=True,
168
- )
187
+ # Set sparse checkout paths
188
+ try:
189
+ subprocess.run(
190
+ ["git", "sparse-checkout", "set", "--skip-checks", *include_paths],
191
+ cwd=tmp_dir,
192
+ check=True,
193
+ capture_output=True,
194
+ text=True,
195
+ env=git_env,
196
+ )
197
+ except subprocess.CalledProcessError as e:
198
+ logger.error(f"Failed to set sparse checkout paths: {e}")
199
+ if e.stderr:
200
+ logger.error(f"Git error: {e.stderr.strip()}")
201
+ raise
169
202
 
170
203
  # -----------------------
171
204
  # Expand include/exclude paths
172
205
  # -----------------------
173
- all_files = expand_paths(tmp_dir, include_paths)
206
+ all_files = __expand_paths(tmp_dir, include_paths)
174
207
 
175
- excluded_files = {f.resolve() for f in expand_paths(tmp_dir, excluded_paths)}
208
+ excluded_files = {f.resolve() for f in __expand_paths(tmp_dir, excluded_paths)}
176
209
 
177
210
  files_to_copy = [f for f in all_files if f.resolve() not in excluded_files]
178
211
 
@@ -0,0 +1,55 @@
1
+ # This file is part of the jebel-quant/rhiza repository
2
+ # (https://github.com/jebel-quant/rhiza).
3
+ #
4
+ """Command to display a welcome message and explain Rhiza.
5
+
6
+ This module provides the welcome command that displays a friendly greeting
7
+ and explains what Rhiza is and how it can help manage configuration templates.
8
+ """
9
+
10
+ from rhiza import __version__
11
+
12
+
13
+ def welcome():
14
+ """Display a welcome message and explain what Rhiza is.
15
+
16
+ Shows a friendly greeting, explains Rhiza's purpose, and provides
17
+ next steps for getting started with the tool.
18
+ """
19
+ welcome_message = f"""
20
+ ╭───────────────────────────────────────────────────────────────╮
21
+ │ │
22
+ │ 🌿 Welcome to Rhiza v{__version__:<43} │
23
+ │ │
24
+ ╰───────────────────────────────────────────────────────────────╯
25
+
26
+ Rhiza helps you maintain consistent configuration across multiple
27
+ Python projects using reusable templates stored in a central repository.
28
+
29
+ ✨ What Rhiza can do for you:
30
+
31
+ • Initialize projects with standard configuration templates
32
+ • Materialize (inject) templates into target repositories
33
+ • Validate template configurations
34
+ • Keep project configurations synchronized
35
+
36
+ 🚀 Getting started:
37
+
38
+ 1. Initialize a project:
39
+ $ rhiza init
40
+
41
+ 2. Customize .github/template.yml to match your needs
42
+
43
+ 3. Materialize templates into your project:
44
+ $ rhiza materialize
45
+
46
+ 📚 Learn more:
47
+
48
+ • View all commands: rhiza --help
49
+ • Project repository: https://github.com/jebel-quant/rhiza-cli
50
+ • Documentation: https://jebel-quant.github.io/rhiza-cli/
51
+
52
+ Happy templating! 🎉
53
+ """
54
+
55
+ print(welcome_message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rhiza
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: Reusable configuration templates for modern Python projects
5
5
  Project-URL: Homepage, https://github.com/jebel-quant/rhiza-cli
6
6
  Project-URL: Repository, https://github.com/jebel-quant/rhiza-cli
@@ -0,0 +1,14 @@
1
+ rhiza/__init__.py,sha256=1jfkGAONm7dH4KwYjvNEyuxrQ-1m2YncxREYCJnTrHA,1933
2
+ rhiza/__main__.py,sha256=Lx0GqVZo6ymm0f18_uYB6E7_SOWwJNYjb73Vr31oLoM,236
3
+ rhiza/cli.py,sha256=Jqe285OWOvbvembO5DXTVITfnFefsjVGZCJuK3EKRT8,5081
4
+ rhiza/models.py,sha256=R2nu_bf-j-U0kPfQXg6u-MSykrdGO9ixOzZoWy8mLCc,3448
5
+ rhiza/commands/__init__.py,sha256=lIkN15MIat-wn9CB1cgUjTzTUQB95LBBAKFK1sGHdCc,1836
6
+ rhiza/commands/init.py,sha256=QsOV_VBnRfSPebydH-fMe3haadboNIAYlOpAIYHtgUs,1936
7
+ rhiza/commands/materialize.py,sha256=FUStZGUr2oDEC-M8V61JnV3W7USj-VS0EHI10a0Mn6Y,9378
8
+ rhiza/commands/validate.py,sha256=_0t9kfylMncm9JmKULn5e7V71XcQdFjlrtuOqZeshPM,5282
9
+ rhiza/commands/welcome.py,sha256=GpDbRSIUigaxS7Di9RIpl2jCOFOlhlQT2vNvCzBR-8U,2001
10
+ rhiza-0.5.6.dist-info/METADATA,sha256=PI_8F886fva98V4uq_toyZ9O8gC8tnOPy-FPSUn0eE4,21278
11
+ rhiza-0.5.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
12
+ rhiza-0.5.6.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
13
+ rhiza-0.5.6.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
14
+ rhiza-0.5.6.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- rhiza/__init__.py,sha256=1jfkGAONm7dH4KwYjvNEyuxrQ-1m2YncxREYCJnTrHA,1933
2
- rhiza/__main__.py,sha256=Lx0GqVZo6ymm0f18_uYB6E7_SOWwJNYjb73Vr31oLoM,236
3
- rhiza/cli.py,sha256=orVHOn569qHm-TffRLpSoJlF5x59dNfQsC2pX7VppYA,4721
4
- rhiza/models.py,sha256=R2nu_bf-j-U0kPfQXg6u-MSykrdGO9ixOzZoWy8mLCc,3448
5
- rhiza/commands/__init__.py,sha256=lIkN15MIat-wn9CB1cgUjTzTUQB95LBBAKFK1sGHdCc,1836
6
- rhiza/commands/init.py,sha256=QsOV_VBnRfSPebydH-fMe3haadboNIAYlOpAIYHtgUs,1936
7
- rhiza/commands/materialize.py,sha256=PcJT7Cq1eXoUZjAe_X1TXn4yUXt1Kft7rCedEe2P-44,7921
8
- rhiza/commands/validate.py,sha256=_0t9kfylMncm9JmKULn5e7V71XcQdFjlrtuOqZeshPM,5282
9
- rhiza-0.5.4.dist-info/METADATA,sha256=2Dh1FhzIIHbDvGu2FSPGHJCG8PQonP9rcZvO4D3MH-M,21278
10
- rhiza-0.5.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
11
- rhiza-0.5.4.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
12
- rhiza-0.5.4.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
13
- rhiza-0.5.4.dist-info/RECORD,,
File without changes