feat: tipo CmdResult y 6 funciones shell — ejecucion de comandos del sistema
Tipo cmd_result (product: Stdout, Stderr, ExitCode). Funciones: Run, RunWithTimeout, RunShell, RunShellTimeout, RunPipe (impuras) y Which (pura). Stubs que documentan devfactory/shell para el registry.
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
|
||||||
|
// Run ejecuta un comando del sistema con timeout de 30 segundos y devuelve el resultado.
|
||||||
|
func Run(name string, args ...string) Result[CmdResult] {
|
||||||
|
// stub — implementation in devfactory/shell
|
||||||
|
return Result[CmdResult]{}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: run_cmd
|
||||||
|
kind: function
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
purity: impure
|
||||||
|
signature: "func Run(name string, args ...string) core.Result[CmdResult]"
|
||||||
|
description: "Ejecuta un comando del sistema con timeout de 30 segundos y devuelve el resultado."
|
||||||
|
tags: [shell, command, process, exec]
|
||||||
|
uses_functions: []
|
||||||
|
uses_types: [cmd_result_go_shell, result_go_core]
|
||||||
|
returns: [result_go_core]
|
||||||
|
returns_optional: false
|
||||||
|
error_type: "error_go_core"
|
||||||
|
imports: []
|
||||||
|
tested: false
|
||||||
|
tests: []
|
||||||
|
test_file_path: ""
|
||||||
|
file_path: "functions/shell/run_cmd.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ejemplo
|
||||||
|
|
||||||
|
```go
|
||||||
|
result := Run("ls", "-la")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Implementacion en devfactory/shell.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
|
||||||
|
// RunWithTimeout ejecuta un comando del sistema con timeout configurable.
|
||||||
|
func RunWithTimeout(name string, timeout time.Duration, args ...string) Result[CmdResult] {
|
||||||
|
// stub — implementation in devfactory/shell
|
||||||
|
return Result[CmdResult]{}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: run_cmd_timeout
|
||||||
|
kind: function
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
purity: impure
|
||||||
|
signature: "func RunWithTimeout(name string, timeout time.Duration, args ...string) core.Result[CmdResult]"
|
||||||
|
description: "Ejecuta un comando del sistema con timeout configurable."
|
||||||
|
tags: [shell, command, process, exec, timeout]
|
||||||
|
uses_functions: []
|
||||||
|
uses_types: [cmd_result_go_shell, result_go_core]
|
||||||
|
returns: [result_go_core]
|
||||||
|
returns_optional: false
|
||||||
|
error_type: "error_go_core"
|
||||||
|
imports: [time]
|
||||||
|
tested: false
|
||||||
|
tests: []
|
||||||
|
test_file_path: ""
|
||||||
|
file_path: "functions/shell/run_cmd_timeout.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ejemplo
|
||||||
|
|
||||||
|
```go
|
||||||
|
result := RunWithTimeout("curl", 5*time.Second, "https://example.com")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Implementacion en devfactory/shell.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
|
||||||
|
// RunPipe encadena multiples comandos con pipe y devuelve el resultado final.
|
||||||
|
func RunPipe(commands ...string) Result[CmdResult] {
|
||||||
|
// stub — implementation in devfactory/shell
|
||||||
|
return Result[CmdResult]{}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: run_pipe
|
||||||
|
kind: function
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
purity: impure
|
||||||
|
signature: "func RunPipe(commands ...string) core.Result[CmdResult]"
|
||||||
|
description: "Encadena multiples comandos con pipe y devuelve el resultado final."
|
||||||
|
tags: [shell, command, process, pipe]
|
||||||
|
uses_functions: []
|
||||||
|
uses_types: [cmd_result_go_shell, result_go_core]
|
||||||
|
returns: [result_go_core]
|
||||||
|
returns_optional: false
|
||||||
|
error_type: "error_go_core"
|
||||||
|
imports: []
|
||||||
|
tested: false
|
||||||
|
tests: []
|
||||||
|
test_file_path: ""
|
||||||
|
file_path: "functions/shell/run_pipe.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ejemplo
|
||||||
|
|
||||||
|
```go
|
||||||
|
result := RunPipe("ls -la", "grep go", "wc -l")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Implementacion en devfactory/shell.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
|
||||||
|
// RunShell ejecuta un comando shell interpretado por /bin/sh.
|
||||||
|
func RunShell(command string) Result[CmdResult] {
|
||||||
|
// stub — implementation in devfactory/shell
|
||||||
|
return Result[CmdResult]{}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: run_shell
|
||||||
|
kind: function
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
purity: impure
|
||||||
|
signature: "func RunShell(command string) core.Result[CmdResult]"
|
||||||
|
description: "Ejecuta un comando shell interpretado por /bin/sh."
|
||||||
|
tags: [shell, command, process, exec]
|
||||||
|
uses_functions: []
|
||||||
|
uses_types: [cmd_result_go_shell, result_go_core]
|
||||||
|
returns: [result_go_core]
|
||||||
|
returns_optional: false
|
||||||
|
error_type: "error_go_core"
|
||||||
|
imports: []
|
||||||
|
tested: false
|
||||||
|
tests: []
|
||||||
|
test_file_path: ""
|
||||||
|
file_path: "functions/shell/run_shell.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ejemplo
|
||||||
|
|
||||||
|
```go
|
||||||
|
result := RunShell("ls -la | grep go")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Implementacion en devfactory/shell.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
|
||||||
|
// RunShellTimeout ejecuta un comando shell con timeout configurable.
|
||||||
|
func RunShellTimeout(command string, timeout time.Duration) Result[CmdResult] {
|
||||||
|
// stub — implementation in devfactory/shell
|
||||||
|
return Result[CmdResult]{}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: run_shell_timeout
|
||||||
|
kind: function
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
purity: impure
|
||||||
|
signature: "func RunShellTimeout(command string, timeout time.Duration) core.Result[CmdResult]"
|
||||||
|
description: "Ejecuta un comando shell con timeout configurable."
|
||||||
|
tags: [shell, command, process, exec, timeout]
|
||||||
|
uses_functions: []
|
||||||
|
uses_types: [cmd_result_go_shell, result_go_core]
|
||||||
|
returns: [result_go_core]
|
||||||
|
returns_optional: false
|
||||||
|
error_type: "error_go_core"
|
||||||
|
imports: [time]
|
||||||
|
tested: false
|
||||||
|
tests: []
|
||||||
|
test_file_path: ""
|
||||||
|
file_path: "functions/shell/run_shell_timeout.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ejemplo
|
||||||
|
|
||||||
|
```go
|
||||||
|
result := RunShellTimeout("long-running-cmd", 30*time.Second)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Implementacion en devfactory/shell.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
|
||||||
|
// Which busca la ruta de un ejecutable en el PATH del sistema. Devuelve None si no existe.
|
||||||
|
func Which(name string) Option[string] {
|
||||||
|
// stub — implementation in devfactory/shell
|
||||||
|
return Option[string]{}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: which
|
||||||
|
kind: function
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
purity: pure
|
||||||
|
signature: "func Which(name string) core.Option[string]"
|
||||||
|
description: "Busca la ruta de un ejecutable en el PATH del sistema. Devuelve None si no existe."
|
||||||
|
tags: [shell, path, lookup]
|
||||||
|
uses_functions: []
|
||||||
|
uses_types: [option_go_core]
|
||||||
|
returns: [option_go_core]
|
||||||
|
returns_optional: false
|
||||||
|
error_type: ""
|
||||||
|
imports: []
|
||||||
|
tested: false
|
||||||
|
tests: []
|
||||||
|
test_file_path: ""
|
||||||
|
file_path: "functions/shell/which.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ejemplo
|
||||||
|
|
||||||
|
```go
|
||||||
|
path := Which("docker")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Implementacion en devfactory/shell.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
// CmdResult almacena el resultado de ejecutar un comando del sistema.
|
||||||
|
// Implementation: github.com/lucasdataproyects/devfactory/shell
|
||||||
|
type CmdResult struct {
|
||||||
|
Stdout string
|
||||||
|
Stderr string
|
||||||
|
ExitCode int
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: cmd_result
|
||||||
|
lang: go
|
||||||
|
domain: shell
|
||||||
|
version: "1.0.0"
|
||||||
|
algebraic: product
|
||||||
|
definition: |
|
||||||
|
type CmdResult struct {
|
||||||
|
Stdout string
|
||||||
|
Stderr string
|
||||||
|
ExitCode int
|
||||||
|
}
|
||||||
|
description: "Resultado de la ejecucion de un comando del sistema con stdout, stderr y codigo de salida."
|
||||||
|
tags: [shell, command, process, result]
|
||||||
|
uses_types: []
|
||||||
|
file_path: "types/shell/cmd_result.go"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Notas
|
||||||
|
|
||||||
|
Tipo producto. Metodos Output(), Lines(), Success(), ToResult() disponibles sobre la instancia.
|
||||||
Reference in New Issue
Block a user