You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Rename config-ssh --diff to --dry-run (#2575)
* feat: Rename config-ssh `--diff` to `--dry-run`
Since the intent between diff and dry-run are different, this change
allows for interactive prompts to be shown during `--dry-run`,
previously prompts were disabled. Dry-run can also be chanied with
`--yes` and `--use-previous-options` for non-interactive modes.
Dry-run is like a normal run with changes replaced by diff.
Fixes#2530
Co-authored-by: Cian Johnston <cian@coder.com>
// Write to stderr to avoid dirtying the diff output.
322
-
_, _=fmt.Fprint(out, "The following changes will be made to your SSH configuration:\n\n")
323
-
for_, change:=rangechanges {
324
-
_, _=fmt.Fprintf(out, " * %s\n", change)
325
-
}
308
+
iflen(changes) >0 {
309
+
dryRunDisclaimer:=""
310
+
ifdryRun {
311
+
dryRunDisclaimer=" (dry-run, no changes will be made)"
312
+
}
313
+
_, err=cliui.Prompt(cmd, cliui.PromptOptions{
314
+
Text: fmt.Sprintf("The following changes will be made to your SSH configuration:\n\n * %s\n\n Continue?%s", strings.Join(changes, "\n * "), dryRunDisclaimer),
Text: fmt.Sprintf("The following changes will be made to your SSH configuration:\n\n * %s\n\n To see changes, run diff:\n\n %s\n\n Continue?", strings.Join(changes, "\n * "), diffCommand),
cliflag.StringVarP(cmd.Flags(), &sshConfigFile, "ssh-config-file", "", "CODER_SSH_CONFIG_FILE", sshDefaultConfigFileName, "Specifies the path to an SSH config.")
396
372
cmd.Flags().StringArrayVarP(&sshConfigOpts.sshOptions, "ssh-option", "o", []string{}, "Specifies additional SSH options to embed in each host stanza.")
397
-
cmd.Flags().BoolVarP(&showDiff, "diff", "D", false, "Show diff of changes that will be made.")
373
+
cmd.Flags().BoolVarP(&dryRun, "dry-run", "n", false, "Perform a trial run with no changes made, showing a diff at the end.")
398
374
cmd.Flags().BoolVarP(&skipProxyCommand, "skip-proxy-command", "", false, "Specifies whether the ProxyCommand option should be skipped. Useful for testing.")
399
375
_=cmd.Flags().MarkHidden("skip-proxy-command")
400
376
cliflag.BoolVarP(cmd.Flags(), &usePreviousOpts, "use-previous-options", "", "CODER_SSH_USE_PREVIOUS_OPTIONS", false, "Specifies whether or not to keep options from previous run of config-ssh.")
0 commit comments