1414 <img src="https://img.shields.io/github/v/tag/goforj/execx?label=version&sort=semver" alt="Latest tag">
1515 <a href="https://codecov.io/gh/goforj/execx" ><img src="https://codecov.io/github/goforj/execx/graph/badge.svg?token=RBB8T6WQ0U"/></a>
1616<!-- test-count:embed:start -->
17- <img src="https://img.shields.io/badge/tests-100 -brightgreen" alt="Tests">
17+ <img src="https://img.shields.io/badge/tests-114 -brightgreen" alt="Tests">
1818<!-- test-count:embed:end -->
1919 <a href="https://goreportcard.com/report/github.com/goforj/execx"><img src="https://goreportcard.com/badge/github.com/goforj/execx" alt="Go Report Card"></a>
2020</p >
@@ -203,8 +203,8 @@ All public APIs are covered by runnable examples under `./examples`, and the tes
203203| ** Process** | [ GracefulShutdown] ( #gracefulshutdown ) [ Interrupt] ( #interrupt ) [ KillAfter] ( #killafter ) [ Send] ( #send ) [ Terminate] ( #terminate ) [ Wait] ( #wait ) |
204204| ** Results** | [ IsExitCode] ( #isexitcode ) [ IsSignal] ( #issignal ) [ OK] ( #ok ) |
205205| ** Streaming** | [ OnStderr] ( #onstderr ) [ OnStdout] ( #onstdout ) [ StderrWriter] ( #stderrwriter ) [ StdoutWriter] ( #stdoutwriter ) |
206+ | ** User Feedback** | [ ShadowPrint] ( #shadowprint ) [ ShadowPrintFormatter] ( #shadowprintformatter ) [ ShadowPrintMask] ( #shadowprintmask ) [ ShadowPrintOff] ( #shadowprintoff ) [ ShadowPrintPrefix] ( #shadowprintprefix ) |
206207| ** WorkingDir** | [ Dir] ( #dir ) |
207- | ** User Feedback** | [ ShadowPrint] ( #shadowprint ) [ ShadowPrintOff] ( #shadowprintoff ) [ ShadowPrintPrefix] ( #shadowprintprefix ) [ ShadowPrintMask] ( #shadowprintmask ) [ ShadowPrintFormatter] ( #shadowprintformatter ) |
208208
209209
210210## Arguments
@@ -289,62 +289,6 @@ fmt.Println(cmd.ShellEscaped())
289289// #string echo 'hello world' 'it'\\''s'
290290```
291291
292- ## User Feedback
293-
294- ### <a id =" shadowprint " ></a >ShadowPrint
295-
296- ShadowPrint writes the shell-escaped command to stderr before and after execution.
297-
298- ``` go
299- _, _ = execx.Command (" printf" , " hi" ).ShadowPrint ().Run ()
300- // execx > printf hi
301- // execx > printf hi (1ms)
302- ```
303-
304- ### <a id =" shadowprintoff " ></a >ShadowPrintOff
305-
306- ShadowPrintOff disables shadow printing for this command chain.
307-
308- ``` go
309- _, _ = execx.Command (" printf" , " hi" ).ShadowPrint ().ShadowPrintOff ().Run ()
310- ```
311-
312- ### <a id =" shadowprintprefix " ></a >ShadowPrintPrefix
313-
314- ShadowPrintPrefix sets the prefix used by ShadowPrint.
315-
316- ``` go
317- _, _ = execx.Command (" printf" , " hi" ).ShadowPrintPrefix (" run" ).Run ()
318- // run > printf hi
319- // run > printf hi (1ms)
320- ```
321-
322- ### <a id =" shadowprintmask " ></a >ShadowPrintMask
323-
324- ShadowPrintMask applies a masker to the shadow-printed command string.
325-
326- ``` go
327- mask := func (cmd string ) string {
328- return strings.ReplaceAll (cmd, " secret" , " ***" )
329- }
330- _, _ = execx.Command (" printf" , " secret" ).ShadowPrintMask (mask).Run ()
331- // execx > printf ***
332- // execx > printf *** (1ms)
333- ```
334-
335- ### <a id =" shadowprintformatter " ></a >ShadowPrintFormatter
336-
337- ShadowPrintFormatter sets a formatter for ShadowPrint output.
338-
339- ``` go
340- formatter := func (ev execx.ShadowEvent ) string {
341- return fmt.Sprintf (" shadow: %s %s " , ev.Phase , ev.Command )
342- }
343- _, _ = execx.Command (" printf" , " hi" ).ShadowPrintFormatter (formatter).Run ()
344- // shadow: before printf hi
345- // shadow: after printf hi
346- ```
347-
348292### <a id =" string " ></a >String
349293
350294String returns a human-readable representation of the command.
@@ -551,17 +495,9 @@ fmt.Println(out)
551495
552496## OS Controls
553497
554- OS controls map to ` syscall.SysProcAttr ` for process/session configuration. Use them when you need process groups, detached sessions, or OS-specific process creation flags. On unsupported platforms they are no-ops.
555-
556498### <a id =" creationflags " ></a >CreationFlags
557499
558- CreationFlags sets Windows process creation flags (for example, create a new process group). It is a no-op on non-Windows platforms.
559-
560- Common flags:
561-
562- - ` execx.CreateNewProcessGroup `
563- - ` execx.CreateNewConsole `
564- - ` execx.CreateNoWindow `
500+ CreationFlags is a no-op on non-Windows platforms; on Windows it sets process creation flags.
565501
566502``` go
567503out , _ := execx.Command (" printf" , " ok" ).CreationFlags (execx.CreateNewProcessGroup ).Output ()
@@ -571,7 +507,7 @@ fmt.Print(out)
571507
572508### <a id =" hidewindow " ></a >HideWindow
573509
574- HideWindow hides console windows on Windows (it sets ` SysProcAttr.HideWindow ` and ` CREATE_NO_WINDOW ` ). It is a no-op on non-Windows platforms.
510+ HideWindow is a no-op on non-Windows platforms; on Windows it hides console windows .
575511
576512``` go
577513out , _ := execx.Command (" printf" , " ok" ).HideWindow (true ).Output ()
@@ -581,7 +517,7 @@ fmt.Print(out)
581517
582518### <a id =" pdeathsig " ></a >Pdeathsig
583519
584- Pdeathsig sets a parent-death signal on Linux so the child receives a signal if the parent exits. It is a no-op on non-Linux platforms .
520+ Pdeathsig sets a parent-death signal on Linux so the child is signaled if the parent exits.
585521
586522``` go
587523out , _ := execx.Command (" printf" , " ok" ).Pdeathsig (syscall.SIGTERM ).Output ()
@@ -591,7 +527,7 @@ fmt.Print(out)
591527
592528### <a id =" setpgid " ></a >Setpgid
593529
594- Setpgid places the child in a new process group. Use this when you want to signal or terminate a group independently of the parent .
530+ Setpgid places the child in a new process group for group signals .
595531
596532``` go
597533out , _ := execx.Command (" printf" , " ok" ).Setpgid (true ).Output ()
@@ -601,7 +537,7 @@ fmt.Print(out)
601537
602538### <a id =" setsid " ></a >Setsid
603539
604- Setsid starts the child in a new session, detaching it from the controlling terminal.
540+ Setsid starts the child in a new session, detaching it from the terminal.
605541
606542``` go
607543out , _ := execx.Command (" printf" , " ok" ).Setsid (true ).Output ()
@@ -830,6 +766,62 @@ fmt.Print(out.String())
830766// hello
831767```
832768
769+ ## User Feedback
770+
771+ ### <a id =" shadowprint " ></a >ShadowPrint
772+
773+ ShadowPrint writes the shell-escaped command to stderr before and after execution.
774+
775+ ``` go
776+ _, _ = execx.Command (" printf" , " hi" ).ShadowPrint ().Run ()
777+ // execx > printf hi
778+ // execx > printf hi (1ms)
779+ ```
780+
781+ ### <a id =" shadowprintformatter " ></a >ShadowPrintFormatter
782+
783+ ShadowPrintFormatter sets a formatter for ShadowPrint output.
784+
785+ ``` go
786+ formatter := func (ev execx.ShadowEvent ) string {
787+ return fmt.Sprintf (" shadow: %s %s " , ev.Phase , ev.Command )
788+ }
789+ _, _ = execx.Command (" printf" , " hi" ).ShadowPrintFormatter (formatter).Run ()
790+ // shadow: before printf hi
791+ // shadow: after printf hi
792+ ```
793+
794+ ### <a id =" shadowprintmask " ></a >ShadowPrintMask
795+
796+ ShadowPrintMask sets a command masker for ShadowPrint output.
797+
798+ ``` go
799+ mask := func (cmd string ) string {
800+ return strings.ReplaceAll (cmd, " secret" , " ***" )
801+ }
802+ _, _ = execx.Command (" printf" , " secret" ).ShadowPrintMask (mask).Run ()
803+ // execx > printf ***
804+ // execx > printf *** (1ms)
805+ ```
806+
807+ ### <a id =" shadowprintoff " ></a >ShadowPrintOff
808+
809+ ShadowPrintOff disables shadow printing for this command chain.
810+
811+ ``` go
812+ _, _ = execx.Command (" printf" , " hi" ).ShadowPrint ().ShadowPrintOff ().Run ()
813+ ```
814+
815+ ### <a id =" shadowprintprefix " ></a >ShadowPrintPrefix
816+
817+ ShadowPrintPrefix sets the prefix used by ShadowPrint.
818+
819+ ``` go
820+ _, _ = execx.Command (" printf" , " hi" ).ShadowPrintPrefix (" run" ).Run ()
821+ // run > printf hi
822+ // run > printf hi (1ms)
823+ ```
824+
833825## WorkingDir
834826
835827### <a id =" dir " ></a >Dir
0 commit comments