File tree 3 files changed +13
-5
lines changed
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package cli
3
3
import (
4
4
"fmt"
5
5
6
+ "golang.org/x/xerrors"
7
+
6
8
"github.com/coder/coder/v2/cli/cliui"
7
9
"github.com/coder/serpent"
8
10
"github.com/coder/serpent/completion"
@@ -45,7 +47,10 @@ func (*RootCmd) completion() *serpent.Command {
45
47
if err == nil {
46
48
return installCompletion (inv , shell )
47
49
}
48
- // Silently continue to the shell selection if detecting failed.
50
+ if ! isTTYOut (inv ) {
51
+ return xerrors .New ("could not detect the current shell, please specify one with --shell or run interactively" )
52
+ }
53
+ // Silently continue to the shell selection if detecting failed in interactive mode
49
54
choice , err := cliui .Select (inv , cliui.SelectOptions {
50
55
Message : "Select a shell to install completion for:" ,
51
56
Options : shellOptions .Choices ,
@@ -71,6 +76,9 @@ func installCompletion(inv *serpent.Invocation, shell completion.Shell) error {
71
76
cliui .Error (inv .Stderr , fmt .Sprintf ("Failed to determine completion path %v" , err ))
72
77
return shell .WriteCompletion (inv .Stdout )
73
78
}
79
+ if ! isTTYOut (inv ) {
80
+ return shell .WriteCompletion (inv .Stdout )
81
+ }
74
82
choice , err := cliui .Select (inv , cliui.SelectOptions {
75
83
Options : []string {
76
84
"Confirm" ,
Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ require go.uber.org/mock v0.4.0
197
197
198
198
require (
199
199
github.com/cespare/xxhash v1.1.0
200
- github.com/coder/serpent v0.7.1-0.20240815055535-d46fb20fa158
200
+ github.com/coder/serpent v0.7.1-0.20240822034013-1b2301f8c920
201
201
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21
202
202
github.com/emersion/go-smtp v0.21.2
203
203
github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47
@@ -283,7 +283,7 @@ require (
283
283
github.com/docker/docker v27.1.1+incompatible // indirect
284
284
github.com/docker/go-connections v0.5.0 // indirect
285
285
github.com/docker/go-units v0.5.0 // indirect
286
- github.com/dustin/go-humanize v1.0.1 // indirect
286
+ github.com/dustin/go-humanize v1.0.1
287
287
github.com/ebitengine/purego v0.6.0-alpha.5 // indirect
288
288
github.com/elastic/go-windows v1.0.0 // indirect
289
289
github.com/felixge/httpsnoop v1.0.4 // indirect
Original file line number Diff line number Diff line change @@ -222,8 +222,8 @@ github.com/coder/quartz v0.1.0 h1:cLL+0g5l7xTf6ordRnUMMiZtRE8Sq5LxpghS63vEXrQ=
222
222
github.com/coder/quartz v0.1.0 /go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA =
223
223
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc =
224
224
github.com/coder/retry v1.5.1 /go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY =
225
- github.com/coder/serpent v0.7.1-0.20240815055535-d46fb20fa158 h1:Z+QHBAsvToUfV0UMDnUy8oqdPyrScn5WKV4mx4yNcXY =
226
- github.com/coder/serpent v0.7.1-0.20240815055535-d46fb20fa158 /go.mod h1:cZFW6/fP+kE9nd/oRkEHJpG6sXCtQ+AX7WMMEHv0Y3Q =
225
+ github.com/coder/serpent v0.7.1-0.20240822034013-1b2301f8c920 h1:RXtavW+kslsKgX2xlroVPqijgTaGHZkn9kvPEP4ALOU =
226
+ github.com/coder/serpent v0.7.1-0.20240822034013-1b2301f8c920 /go.mod h1:cZFW6/fP+kE9nd/oRkEHJpG6sXCtQ+AX7WMMEHv0Y3Q =
227
227
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 h1:YoUSJ19E8AtuUFVYBpXuOD6a/zVP3rcxezNsoDseTUw =
228
228
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 /go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ =
229
229
github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374 h1:a5Eg7D5e2oAc0tN56ee4yxtiTo76ztpRlk6geljaZp8 =
You can’t perform that action at this time.
0 commit comments