Skip to content

Commit c65cc16

Browse files
committed
Add environment.rebuild and environment.delete
1 parent e8bf6bf commit c65cc16

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/appose/environment.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from pathlib import Path
1313
from typing import TYPE_CHECKING
1414

15+
from .service import Service
1516
from .syntax import GroovySyntax, PythonSyntax
1617
from .util.filepath import find_exe
17-
from .service import Service
1818

1919
if TYPE_CHECKING:
2020
from .builder import Builder
@@ -84,6 +84,31 @@ def type(self) -> str:
8484
builder = self.builder()
8585
return builder.env_type() if builder else "unknown"
8686

87+
def rebuild(self) -> Environment:
88+
"""
89+
Rebuilds this environment from scratch.
90+
This deletes the existing environment directory and rebuilds it using the
91+
current builder configuration.
92+
93+
Returns:
94+
The newly rebuilt environment.
95+
Raises:
96+
BuildException: If something goes wrong during rebuild.
97+
"""
98+
return self.builder().rebuild()
99+
100+
def delete(self) -> Environment:
101+
"""
102+
Deletes the existing environment directory, if any.
103+
104+
Returns:
105+
This environment, for fluid chaining.
106+
Raises:
107+
OSError: If something goes wrong during deletion.
108+
"""
109+
self.builder().delete()
110+
return self
111+
87112
def python(self) -> Service:
88113
"""
89114
Create a Python script service.

0 commit comments

Comments
 (0)