@@ -41,24 +41,38 @@ func (r *RootCmd) currentOrganization() *clibase.Cmd {
41
41
cliui .TableFormat ([]codersdk.Organization {}, []string {"id" ,"name" ,"default" }),
42
42
cliui .JSONFormat (),
43
43
)
44
+ onlyID = false
44
45
)
45
46
cmd := & clibase.Cmd {
46
47
Use :"current" ,
47
48
Short :"Show the current selected organization the cli will use" ,
48
49
Middleware :clibase .Chain (
49
50
r .InitClient (client ),
50
51
),
52
+ Options : clibase.OptionSet {
53
+ {
54
+ Name :"only-id" ,
55
+ Description :"Only print the organization ID." ,
56
+ Required :false ,
57
+ Flag :"only-id" ,
58
+ Value :clibase .BoolOf (& onlyID ),
59
+ },
60
+ },
51
61
Handler :func (inv * clibase.Invocation )error {
52
62
org ,err := CurrentOrganization (r ,inv ,client )
53
63
if err != nil {
54
64
return err
55
65
}
56
66
57
- out ,err := formatter .Format (inv .Context (), []codersdk.Organization {org })
58
- if err != nil {
59
- return err
67
+ if onlyID {
68
+ _ ,_ = fmt .Fprintf (inv .Stdout ,"%s\n " ,org .ID )
69
+ }else {
70
+ out ,err := formatter .Format (inv .Context (), []codersdk.Organization {org })
71
+ if err != nil {
72
+ return err
73
+ }
74
+ _ ,err = fmt .Fprintf (inv .Stdout ,out )
60
75
}
61
- _ ,err = fmt .Fprintln (inv .Stdout ,out )
62
76
return nil
63
77
},
64
78
}