-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yangyile
committed
Dec 16, 2024
1 parent
5f4b126
commit cb31b8d
Showing
5 changed files
with
172 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/yyle88/erero" | ||
"github.com/yyle88/eroticgo" | ||
) | ||
|
||
func ShowCommand(message string) { | ||
fmt.Println(eroticgo.BLUE.Sprint("---")) | ||
fmt.Println(eroticgo.BLUE.Sprint(message)) | ||
fmt.Println(eroticgo.BLUE.Sprint("---")) | ||
} | ||
|
||
func ShowMessage(message string) { | ||
fmt.Println(eroticgo.GREEN.Sprint("---")) | ||
fmt.Println(eroticgo.GREEN.Sprint(message)) | ||
fmt.Println(eroticgo.GREEN.Sprint("---")) | ||
} | ||
|
||
func ShowWarning(message string) { | ||
fmt.Println(eroticgo.RED.Sprint("---")) | ||
fmt.Println(eroticgo.RED.Sprint(message)) | ||
fmt.Println(eroticgo.RED.Sprint("---")) | ||
} | ||
|
||
// WarpMessage handles the output of the executed command and wraps errors. | ||
// WarpMessage 处理执行命令的输出,并在出现错误时封装错误信息。 | ||
func WarpMessage(output []byte, err error, debugMode bool) ([]byte, error) { | ||
if err != nil { | ||
if debugMode { | ||
if len(output) > 0 { | ||
ShowWarning(string(output)) | ||
} else { | ||
ShowWarning(err.Error()) | ||
} | ||
} | ||
return output, erero.Wro(err) | ||
} | ||
if debugMode { | ||
if len(output) > 0 { | ||
ShowMessage(string(output)) | ||
} | ||
} | ||
return output, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
package osexec | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/yyle88/eroticgo" | ||
) | ||
|
||
type CMC = CommandConfig | ||
|
||
func NewCMC() *CMC { | ||
return NewCommandConfig() | ||
} | ||
|
||
var debugModeOpen = true | ||
type OsCommand = CommandConfig | ||
|
||
func SetDebugMode(enable bool) { | ||
debugModeOpen = enable | ||
func NewOsCommand() *OsCommand { | ||
return NewCommandConfig() | ||
} | ||
|
||
func showMessage(message string) { | ||
fmt.Println(eroticgo.BLUE.Sprint("---")) | ||
fmt.Println(eroticgo.BLUE.Sprint(message)) | ||
fmt.Println(eroticgo.BLUE.Sprint("---")) | ||
} | ||
var debugModeOpen = true | ||
|
||
func showWarning(message string) { | ||
fmt.Println(eroticgo.RED.Sprint("---")) | ||
fmt.Println(eroticgo.RED.Sprint(message)) | ||
fmt.Println(eroticgo.RED.Sprint("---")) | ||
func SetDebugMode(enable bool) { | ||
debugModeOpen = enable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters