From 6f7b878074e898edc4942117d590f51d79a4d009 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 9 May 2021 20:20:16 +0200 Subject: [PATCH] changes: add "(hidden)" to commands with no output and quiet mode This should make it more obvious why these commands are not shown. --- cmd/safcm/sync_changes.go | 2 +- cmd/safcm/sync_changes_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/safcm/sync_changes.go b/cmd/safcm/sync_changes.go index f597ae1..2650bb4 100644 --- a/cmd/safcm/sync_changes.go +++ b/cmd/safcm/sync_changes.go @@ -205,7 +205,7 @@ func (s *Sync) formatCommandChanges(changes []safcm.CommandChange) string { fmt.Fprintf(&buf, "executed %d command(s)", len(changes)) } if noOutput > 0 && !s.config.DryRun { - fmt.Fprintf(&buf, ", %d with no output", noOutput) + fmt.Fprintf(&buf, ", %d with no output (hidden)", noOutput) } if noOutput != len(changes) { fmt.Fprintf(&buf, ":") diff --git a/cmd/safcm/sync_changes_test.go b/cmd/safcm/sync_changes_test.go index feb8dd3..219373c 100644 --- a/cmd/safcm/sync_changes_test.go +++ b/cmd/safcm/sync_changes_test.go @@ -1083,7 +1083,7 @@ func TestFormatCommandChanges(t *testing.T) { Error: "fake error", }, }, - `executed 5 command(s), 1 with no output: + `executed 5 command(s), 1 with no output (hidden): "fake command": > fake output > \ No newline at end of file @@ -1126,7 +1126,7 @@ func TestFormatCommandChanges(t *testing.T) { Error: "fake error", }, }, - "executed 5 command(s), 1 with no output:\n\x1b[36m\"fake command\"\x1b[0m:\n > fake output\n > \\ No newline at end of file\n\x1b[36m\"fake command with newline\"\x1b[0m:\n > fake output\n\x1b[36m\"fake command with more output\"\x1b[0m:\n > fake out\n > fake put\n > fake\n\x1b[36m\"fake failed command\"\x1b[0m, failed: \"fake error\":\n > fake output\n > \\ No newline at end of file\n", + "executed 5 command(s), 1 with no output (hidden):\n\x1b[36m\"fake command\"\x1b[0m:\n > fake output\n > \\ No newline at end of file\n\x1b[36m\"fake command with newline\"\x1b[0m:\n > fake output\n\x1b[36m\"fake command with more output\"\x1b[0m:\n > fake out\n > fake put\n > fake\n\x1b[36m\"fake failed command\"\x1b[0m, failed: \"fake error\":\n > fake output\n > \\ No newline at end of file\n", }, { @@ -1142,7 +1142,7 @@ func TestFormatCommandChanges(t *testing.T) { Command: "fake command with no output", }, }, - `executed 2 command(s), 2 with no output + `executed 2 command(s), 2 with no output (hidden) `, }, @@ -1160,7 +1160,7 @@ func TestFormatCommandChanges(t *testing.T) { Command: "fake command with no output", }, }, - `executed 2 command(s), 1 with no output: + `executed 2 command(s), 1 with no output (hidden): "fake command with no output but error", failed: "fake error" `, }, -- 2.43.2