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