Browse Source

refactor: add default name/lines to Script Action

Sam Jaffe 1 tháng trước cách đây
mục cha
commit
c3aacc8a59
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      src/cipy/action.py

+ 6 - 0
src/cipy/action.py

@@ -103,6 +103,12 @@ class Script(Action):
 
     shell: Shell = Shell.DEFAULT
     script: str
+    _lines: list[str] = PrivateAttr()
+
+    def model_post_init(self, context: Any, /) -> None:
+        self._lines = self.script.splitlines()
+        if self.name is None:
+            self.name = self._lines[0]
 
     @final
     @cipy.runner.ipc