Don't suggest that the change already took place. "dry-run" is still
printed to make it clear why no changes were made.
[]string{"-n", "no-effect-commands.example.org"},
`<LOG>[info] [no-effect-commands.example.org] remote helper upload in progress
<LOG>[info] [no-effect-commands.example.org]
[]string{"-n", "no-effect-commands.example.org"},
`<LOG>[info] [no-effect-commands.example.org] remote helper upload in progress
<LOG>[info] [no-effect-commands.example.org]
-executed 2 command(s): (dry-run)
+will execute 2 command(s): (dry-run)
"echo this is a command"
"true"
`,
"echo this is a command"
"true"
`,
<LOG>[verbose] [no-effect-commands.example.org] host groups: all <DET> <DET> no-effect-commands.example.org
<LOG>[verbose] [no-effect-commands.example.org] host group priorities (descending): no-effect-commands.example.org
<LOG>[info] [no-effect-commands.example.org]
<LOG>[verbose] [no-effect-commands.example.org] host groups: all <DET> <DET> no-effect-commands.example.org
<LOG>[verbose] [no-effect-commands.example.org] host group priorities (descending): no-effect-commands.example.org
<LOG>[info] [no-effect-commands.example.org]
-executed 2 command(s): (dry-run)
+will execute 2 command(s): (dry-run)
"echo this is a command"
"true"
`,
"echo this is a command"
"true"
`,
[]string{"-n", "no-effect-commands-failing.example.org"},
`<LOG>[info] [no-effect-commands-failing.example.org] remote helper upload in progress
<LOG>[info] [no-effect-commands-failing.example.org]
[]string{"-n", "no-effect-commands-failing.example.org"},
`<LOG>[info] [no-effect-commands-failing.example.org] remote helper upload in progress
<LOG>[info] [no-effect-commands-failing.example.org]
-executed 2 command(s): (dry-run)
+will execute 2 command(s): (dry-run)
"echo this is a command"
"echo failing; false"
`,
"echo this is a command"
"echo failing; false"
`,
<LOG>[verbose] [no-effect-commands-failing.example.org] host groups: all <DET> <DET> no-effect-commands-failing.example.org
<LOG>[verbose] [no-effect-commands-failing.example.org] host group priorities (descending): no-effect-commands-failing.example.org
<LOG>[info] [no-effect-commands-failing.example.org]
<LOG>[verbose] [no-effect-commands-failing.example.org] host groups: all <DET> <DET> no-effect-commands-failing.example.org
<LOG>[verbose] [no-effect-commands-failing.example.org] host group priorities (descending): no-effect-commands-failing.example.org
<LOG>[info] [no-effect-commands-failing.example.org]
-executed 2 command(s): (dry-run)
+will execute 2 command(s): (dry-run)
"echo this is a command"
"echo failing; false"
`,
"echo this is a command"
"echo failing; false"
`,
func (s *Sync) formatFileChanges(changes []safcm.FileChange) string {
var buf strings.Builder
func (s *Sync) formatFileChanges(changes []safcm.FileChange) string {
var buf strings.Builder
- fmt.Fprintf(&buf, "changed %d file(s):", len(changes))
- fmt.Fprintf(&buf, " (dry-run)")
+ fmt.Fprintf(&buf, "will change %d file(s): (dry-run)\n",
+ len(changes))
+ } else {
+ fmt.Fprintf(&buf, "changed %d file(s):\n", len(changes))
- fmt.Fprintf(&buf, "\n")
for _, x := range changes {
fmt.Fprintf(&buf, "%s:", s.formatTarget(x.Path))
for _, x := range changes {
fmt.Fprintf(&buf, "%s:", s.formatTarget(x.Path))
}
fmt.Fprintf(&buf, "\n")
}
}
fmt.Fprintf(&buf, "\n")
}
return buf.String()
}
func formatFileType(info safcm.FileChangeInfo) string {
return buf.String()
}
func formatFileType(info safcm.FileChangeInfo) string {
func (s *Sync) formatPackageChanges(changes []safcm.PackageChange) string {
var buf strings.Builder
func (s *Sync) formatPackageChanges(changes []safcm.PackageChange) string {
var buf strings.Builder
- fmt.Fprintf(&buf, "installed %d package(s):", len(changes))
- fmt.Fprintf(&buf, " (dry-run)")
+ fmt.Fprintf(&buf, "will install %d package(s): (dry-run)\n",
+ len(changes))
+ } else {
+ fmt.Fprintf(&buf, "installed %d package(s):\n", len(changes))
- fmt.Fprintf(&buf, "\n")
for _, x := range changes {
// TODO: indicate if installation failed
fmt.Fprintf(&buf, "%s\n", s.formatTarget(x.Name))
for _, x := range changes {
// TODO: indicate if installation failed
fmt.Fprintf(&buf, "%s\n", s.formatTarget(x.Name))
func (s *Sync) formatServiceChanges(changes []safcm.ServiceChange) string {
var buf strings.Builder
func (s *Sync) formatServiceChanges(changes []safcm.ServiceChange) string {
var buf strings.Builder
- fmt.Fprintf(&buf, "modified %d service(s):", len(changes))
- fmt.Fprintf(&buf, " (dry-run)")
+ fmt.Fprintf(&buf, "will modify %d service(s): (dry-run)\n",
+ len(changes))
+ } else {
+ fmt.Fprintf(&buf, "modified %d service(s):\n", len(changes))
- fmt.Fprintf(&buf, "\n")
for _, x := range changes {
var info []string
if x.Started {
for _, x := range changes {
var info []string
if x.Started {
}
var buf strings.Builder
}
var buf strings.Builder
- fmt.Fprintf(&buf, "executed %d command(s)", len(changes))
+ if s.config.DryRun {
+ fmt.Fprintf(&buf, "will execute %d command(s)", len(changes))
+ } else {
+ fmt.Fprintf(&buf, "executed %d command(s)", len(changes))
+ }
if noOutput > 0 && !s.config.DryRun {
fmt.Fprintf(&buf, ", %d with no output", noOutput)
}
if noOutput > 0 && !s.config.DryRun {
fmt.Fprintf(&buf, ", %d with no output", noOutput)
}
- "\nexecuted 5 command(s): (dry-run)\n\"fake command\"\n\"fake command with no output\"\n\"fake command with newline\"\n\"fake command with more output\"\n\"fake failed command\"\n",
+ "\nwill execute 5 command(s): (dry-run)\n\"fake command\"\n\"fake command with no output\"\n\"fake command with newline\"\n\"fake command with more output\"\n\"fake failed command\"\n",
},
{
"command changes only, quiet & dry-run",
},
{
"command changes only, quiet & dry-run",
- "executed 5 command(s) (dry-run)\n",
+ "will execute 5 command(s) (dry-run)\n",
- `changed 1 file(s): (dry-run)
+ `will change 1 file(s): (dry-run)
"file": created, file, user(1000) group(2000), 0644
`,
},
"file": created, file, user(1000) group(2000), 0644
`,
},
- "changed 1 file(s): (dry-run)\n\x1B[36m\"file\"\x1B[0m: \x1B[32mcreated\x1B[0m, file, user(1000) group(2000), 0644\n",
+ "will change 1 file(s): (dry-run)\n\x1B[36m\"file\"\x1B[0m: \x1B[32mcreated\x1B[0m, file, user(1000) group(2000), 0644\n",
Name: "package-two",
},
},
Name: "package-two",
},
},
- `installed 2 package(s): (dry-run)
+ `will install 2 package(s): (dry-run)
"package-one"
"package-two"
`,
"package-one"
"package-two"
`,
Name: "package-two",
},
},
Name: "package-two",
},
},
- "installed 2 package(s): (dry-run)\n\x1b[36m\"package-one\"\x1b[0m\n\x1b[36m\"package-two\"\x1b[0m\n",
+ "will install 2 package(s): (dry-run)\n\x1b[36m\"package-one\"\x1b[0m\n\x1b[36m\"package-two\"\x1b[0m\n",
- `modified 3 service(s): (dry-run)
+ `will modify 3 service(s): (dry-run)
"service-one": started
"service-two": enabled
"service-three": started, enabled
"service-one": started
"service-two": enabled
"service-three": started, enabled
- "modified 3 service(s): (dry-run)\n\x1b[36m\"service-one\"\x1b[0m: started\n\x1b[36m\"service-two\"\x1b[0m: enabled\n\x1b[36m\"service-three\"\x1b[0m: started, enabled\n",
+ "will modify 3 service(s): (dry-run)\n\x1b[36m\"service-one\"\x1b[0m: started\n\x1b[36m\"service-two\"\x1b[0m: enabled\n\x1b[36m\"service-three\"\x1b[0m: started, enabled\n",
Command: "fake command",
},
},
Command: "fake command",
},
},
- `executed 1 command(s): (dry-run)
+ `will execute 1 command(s): (dry-run)
Command: "fake command",
},
},
Command: "fake command",
},
},
- "executed 1 command(s): (dry-run)\n\x1b[36m\"fake command\"\x1b[0m\n",
+ "will execute 1 command(s): (dry-run)\n\x1b[36m\"fake command\"\x1b[0m\n",
Command: "fake failed command",
},
},
Command: "fake failed command",
},
},
- `executed 5 command(s) (dry-run)
+ `will execute 5 command(s) (dry-run)