- Notifications
You must be signed in to change notification settings - Fork1
simple utils to use golang os/exec
License
NotificationsYou must be signed in to change notification settings
yyle88/osexec
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Simple utilities to use Golang'sos/exec
package.
- Custom Execution Configurations: Execute commands with customizable environment variables, working paths, and shell options.
go get github.com/yyle88/osexec
CommandConfig
structure provides a flexible way to configure and execute commands. You can set custom environment variables, directories, shell types, and debug options using a chainable interface.
Creates and returns a newCommandConfig
instance.
config:=osexec.NewCommandConfig()
- *WithEnvs(envs []string)CommandConfig: Sets custom environment variables.
- *WithPath(path string)CommandConfig: Sets the working path.
- *WithShellType(shellType string)CommandConfig: Sets the shell type (e.g.,
bash
). - *WithShellFlag(shellFlag string)CommandConfig: Sets the shell flag (e.g.,
-c
). - *WithShell(shellType, shellFlag string)CommandConfig: Sets shell type and flag.
- *WithBash()CommandConfig: Configures the command to use
bash -c
. - *WithZsh()CommandConfig: Configures the command to use
zsh -c
. - *WithSh()CommandConfig: Configures the command to use
sh -c
. - *WithDebugMode(debugMode bool)CommandConfig: Enables / disables debug mode.
package mainimport ("fmt""github.com/yyle88/osexec")funcmain() {// Create a new CommandConfig instance and set the working directory and debug modeconfig:=osexec.NewCommandConfig().WithPath("/path/to/directoryName").WithDebugMode(true)output,err:=config.Exec("echo","Hello, World!")iferr!=nil {fmt.Println("Error:",err)}else {fmt.Println("Output:",string(output))}}
osexec
is open-source and released under the MIT License. See theLICENSE file for more information.
Welcome to contribute to this project by submitting pull requests or reporting issues.
If you find this package helpful, give it a star on GitHub!
Thank you for your support!
Happy Coding withosexec
! 🎉
Give me stars. Thank you!!!
About
simple utils to use golang os/exec
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published