@@ -176,19 +176,29 @@ func configSSH() *cobra.Command {
176
176
}
177
177
lastCoderConfig := sshCoderConfigParseLastOptions (bytes .NewReader (coderConfigRaw ), coderConfig .sshConfigDefaultFile )
178
178
179
- // Only prompt when no arguments are provided and avoid
180
- // prompting in diff mode (unexpected behavior).
181
- if ! showDiff && coderConfig .isZero () && ! lastCoderConfig .isZero () {
179
+ // Avoid prompting in diff mode (unexpected behavior).
180
+ if ! showDiff && ! coderConfig .equal (lastCoderConfig ) {
181
+ newOpts := coderConfig .asList ()
182
+ newOptsMsg := "\n \n New options: none"
183
+ if len (newOpts ) > 0 {
184
+ newOptsMsg = fmt .Sprintf ("\n \n New options:\n * %s" , strings .Join (newOpts , "\n * " ))
185
+ }
186
+ oldOpts := lastCoderConfig .asList ()
187
+ oldOptsMsg := "\n \n Previouss options: none"
188
+ if len (oldOpts ) > 0 {
189
+ oldOptsMsg = fmt .Sprintf ("\n \n Previous options:\n * %s" , strings .Join (oldOpts , "\n * " ))
190
+ }
191
+
182
192
line , err := cliui .Prompt (cmd , cliui.PromptOptions {
183
- Text : fmt .Sprintf ("Found previous configuration option(s): \n \n - %s \n \n Use previous option(s) ?" , strings . Join ( lastCoderConfig . asList (), " \n - " ) ),
193
+ Text : fmt .Sprintf ("New options differ from previous options:%s%s \n \n Use new options ?" , newOptsMsg , oldOptsMsg ),
184
194
IsConfirm : true ,
185
195
})
186
196
if err != nil {
187
197
// TODO(mafredri): Better way to differ between "no" and Ctrl+C?
188
198
if line == "" && xerrors .Is (err , cliui .Canceled ) {
189
199
return nil
190
200
}
191
- } else {
201
+ // Selecting "no" will use the last config.
192
202
coderConfig = lastCoderConfig
193
203
}
194
204
_ , _ = fmt .Fprint (out , "\n " )
0 commit comments