55
66module Kuby
77 class CLIBase
8- extend T ::Sig
8+ # extend T::Sig
99
10- BeforeCallback = T . type_alias { T . proc . params ( cmd : T ::Array [ String ] ) . void }
11- AfterCallback = T . type_alias do
12- T . proc . params ( cmd : T ::Array [ String ] , last_status : T . nilable ( Process ::Status ) ) . void
13- end
10+ # BeforeCallback = T.type_alias { T.proc.params(cmd: T::Array[String]).void }
11+ # AfterCallback = T.type_alias do
12+ # T.proc.params(cmd: T::Array[String], last_status: T.nilable(Process::Status)).void
13+ # end
1414
15- T ::Sig ::WithoutRuntime . sig { returns ( T . nilable ( Process ::Status ) ) }
15+ # T::Sig::WithoutRuntime.sig { returns(T.nilable(Process::Status)) }
1616 def last_status
1717 Thread . current [ status_key ]
1818 end
1919
20- T ::Sig ::WithoutRuntime . sig { params ( block : BeforeCallback ) . void }
20+ # T::Sig::WithoutRuntime.sig { params(block: BeforeCallback).void }
2121 def before_execute ( &block )
22- @before_execute = T . let ( @before_execute , T . nilable ( T ::Array [ BeforeCallback ] ) )
22+ # @before_execute = T.let(@before_execute, T.nilable(T::Array[BeforeCallback]))
2323 @before_execute ||= [ ]
2424 @before_execute << block
2525 end
2626
27- T ::Sig ::WithoutRuntime . sig { params ( block : AfterCallback ) . void }
27+ # T::Sig::WithoutRuntime.sig { params(block: AfterCallback).void }
2828 def after_execute ( &block )
29- @after_execute = T . let ( @after_execute , T . nilable ( T ::Array [ AfterCallback ] ) )
29+ # @after_execute = T.let(@after_execute, T.nilable(T::Array[AfterCallback]))
3030 @after_execute ||= [ ]
3131 @after_execute << block
3232 end
3333
34- T ::Sig ::WithoutRuntime . sig {
35- params (
36- out : T . any ( IO , StringIO ) ,
37- err : T . any ( IO , StringIO ) ,
38- block : T . proc . void
39- ) . void
40- }
34+ # T::Sig::WithoutRuntime.sig {
35+ # params(
36+ # out: T.any(IO, StringIO),
37+ # err: T.any(IO, StringIO),
38+ # block: T.proc.void
39+ # ).void
40+ # }
4141 def with_pipes ( out = STDOUT , err = STDERR , &block )
4242 previous_stdout = self . stdout
4343 previous_stderr = self . stderr
@@ -49,34 +49,34 @@ def with_pipes(out = STDOUT, err = STDERR, &block)
4949 self . stderr = previous_stderr
5050 end
5151
52- T ::Sig ::WithoutRuntime . sig { returns ( T . nilable ( T . any ( IO , StringIO ) ) ) }
52+ # T::Sig::WithoutRuntime.sig { returns(T.nilable(T.any(IO, StringIO))) }
5353 def stdout
5454 Thread . current [ stdout_key ] || STDOUT
5555 end
5656
57- T ::Sig ::WithoutRuntime . sig { params ( new_stdout : T . nilable ( T . any ( IO , StringIO ) ) ) . void }
57+ # T::Sig::WithoutRuntime.sig { params(new_stdout: T.nilable(T.any(IO, StringIO))).void }
5858 def stdout = ( new_stdout )
5959 Thread . current [ stdout_key ] = new_stdout
6060 end
6161
62- T ::Sig ::WithoutRuntime . sig { returns ( T . nilable ( T . any ( IO , StringIO ) ) ) }
62+ # T::Sig::WithoutRuntime.sig { returns(T.nilable(T.any(IO, StringIO))) }
6363 def stderr
6464 Thread . current [ stderr_key ] || STDERR
6565 end
6666
67- T ::Sig ::WithoutRuntime . sig { params ( new_stderr : T . nilable ( T . any ( IO , StringIO ) ) ) . void }
67+ # T::Sig::WithoutRuntime.sig { params(new_stderr: T.nilable(T.any(IO, StringIO))).void }
6868 def stderr = ( new_stderr )
6969 Thread . current [ stderr_key ] = new_stderr
7070 end
7171
7272 private
7373
74- T ::Sig ::WithoutRuntime . sig {
75- params (
76- cmd : T ::Array [ String ] ,
77- block : T . proc . params ( stdin : IO ) . void
78- ) . void
79- }
74+ # T::Sig::WithoutRuntime.sig {
75+ # params(
76+ # cmd: T::Array[String],
77+ # block: T.proc.params(stdin: IO).void
78+ # ).void
79+ # }
8080 def open3_w ( cmd , &block )
8181 run_before_callbacks ( cmd )
8282 cmd_s = cmd . join ( ' ' )
@@ -99,20 +99,20 @@ def open3_w(cmd, &block)
9999 yield ( p_stdin )
100100
101101 p_stdin . close
102- self . last_status = T . cast ( wait_thread . value , Process :: Status )
102+ self . last_status = wait_thread . value
103103 run_after_callbacks ( cmd )
104104 wait_thread . join
105105 end
106106 end
107107
108- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . void }
108+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
109109 def execc ( cmd )
110110 run_before_callbacks ( cmd )
111111 cmd_s = cmd . join ( ' ' )
112112 exec ( cmd_s )
113113 end
114114
115- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . void }
115+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
116116 def systemm ( cmd )
117117 if stdout == STDOUT && stderr == STDERR
118118 systemm_default ( cmd )
@@ -121,7 +121,7 @@ def systemm(cmd)
121121 end
122122 end
123123
124- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . void }
124+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
125125 def systemm_default ( cmd )
126126 run_before_callbacks ( cmd )
127127 cmd_s = cmd . join ( ' ' )
@@ -131,7 +131,7 @@ def systemm_default(cmd)
131131 end
132132 end
133133
134- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . void }
134+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
135135 def systemm_open3 ( cmd )
136136 run_before_callbacks ( cmd )
137137 cmd_s = cmd . join ( ' ' )
@@ -152,14 +152,14 @@ def systemm_open3(cmd)
152152 end
153153
154154 p_stdin . close
155- self . last_status = T . cast ( wait_thread . value , Process :: Status )
155+ self . last_status = wait_thread . value
156156 run_after_callbacks ( cmd )
157157 wait_thread . join
158158 end
159159 end
160160
161161
162- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . returns ( String ) }
162+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).returns(String) }
163163 def backticks ( cmd )
164164 if stdout == STDOUT && stderr == STDERR
165165 backticks_default ( cmd )
@@ -168,7 +168,7 @@ def backticks(cmd)
168168 end
169169 end
170170
171- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . returns ( String ) }
171+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).returns(String) }
172172 def backticks_default ( cmd )
173173 run_before_callbacks ( cmd )
174174 cmd_s = cmd . join ( ' ' )
@@ -178,7 +178,7 @@ def backticks_default(cmd)
178178 end
179179 end
180180
181- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . returns ( String ) }
181+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).returns(String) }
182182 def backticks_open3 ( cmd )
183183 run_before_callbacks ( cmd )
184184 cmd_s = cmd . join ( ' ' )
@@ -200,40 +200,40 @@ def backticks_open3(cmd)
200200 end
201201
202202 p_stdin . close
203- self . last_status = T . cast ( wait_thread . value , Process :: Status )
203+ self . last_status = wait_thread . value
204204 run_after_callbacks ( cmd )
205205 wait_thread . join
206206 end
207207
208208 result . string
209209 end
210210
211- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . void }
211+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
212212 def run_before_callbacks ( cmd )
213213 ( @before_execute || [ ] ) . each { |cb | cb . call ( cmd ) }
214214 end
215215
216- T ::Sig ::WithoutRuntime . sig { params ( cmd : T ::Array [ String ] ) . void }
216+ # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
217217 def run_after_callbacks ( cmd )
218218 ( @after_execute || [ ] ) . each { |cb | cb . call ( cmd , last_status ) }
219219 end
220220
221- T ::Sig ::WithoutRuntime . sig { params ( status : Process ::Status ) . void }
221+ # T::Sig::WithoutRuntime.sig { params(status: Process::Status).void }
222222 def last_status = ( status )
223223 Thread . current [ status_key ] = status
224224 end
225225
226- T ::Sig ::WithoutRuntime . sig { returns ( Symbol ) }
226+ # T::Sig::WithoutRuntime.sig { returns(Symbol) }
227227 def status_key
228228 raise NotImplementedError , "#{ __method__ } must be defined in derived classes"
229229 end
230230
231- T ::Sig ::WithoutRuntime . sig { returns ( Symbol ) }
231+ # T::Sig::WithoutRuntime.sig { returns(Symbol) }
232232 def stdout_key
233233 raise NotImplementedError , "#{ __method__ } must be defined in derived classes"
234234 end
235235
236- T ::Sig ::WithoutRuntime . sig { returns ( Symbol ) }
236+ # T::Sig::WithoutRuntime.sig { returns(Symbol) }
237237 def stderr_key
238238 raise NotImplementedError , "#{ __method__ } must be defined in derived classes"
239239 end
0 commit comments