Skip to content

Commit 56cc765

Browse files
committed
add option to hide command line
This can be used for commands that are called with sensitive arguments like passwords
1 parent c743d72 commit 56cc765

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

conproc.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ func New(opts Options) (*ConsoleProcess, error) {
7070
// This makes the behavior more consistent, as it isolates the signal handling from
7171
// the parent processes, which are dependent on the test environment.
7272
cmd.SysProcAttr = osutils.SysProcAttrForNewProcessGroup()
73-
fmt.Printf("Spawning '%s' from %s\n", osutils.CmdString(cmd), opts.WorkDirectory)
73+
cmdString := osutils.CmdString(cmd)
74+
if opts.HideCmdLine {
75+
cmdString = "*****"
76+
}
77+
fmt.Printf("Spawning '%s' from %s\n", cmdString, opts.WorkDirectory)
7478

7579
conOpts := []expect.ConsoleOpt{
7680
expect.WithDefaultTimeout(opts.DefaultTimeout),

opts.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Options struct {
2727
ObserveExpect expect.ExpectObserver
2828
CmdName string
2929
Args []string
30+
HideCmdLine bool
3031
ExtraOpts []expect.ConsoleOpt
3132
}
3233

0 commit comments

Comments
 (0)