@@ -9,9 +9,16 @@ import (
99 "github.com/onecli/onecli-cli/pkg/validate"
1010)
1111
12+ // configureResult is the structured response after configuring an app.
13+ type configureResult struct {
14+ App string `json:"app"`
15+ Status string `json:"status"`
16+ }
17+
1218// AppsCmd is the `onecli apps` command group.
1319type AppsCmd struct {
1420 List AppsListCmd `cmd:"" help:"List all apps with config and connection status."`
21+ Get AppsGetCmd `cmd:"" help:"Get a single app with setup guidance."`
1522 Configure AppsConfigureCmd `cmd:"" help:"Save OAuth credentials (BYOC) for a provider."`
1623 Remove AppsRemoveCmd `cmd:"" help:"Remove OAuth credentials for a provider."`
1724 Disconnect AppsDisconnectCmd `cmd:"" help:"Disconnect an app connection."`
@@ -42,6 +49,34 @@ func (c *AppsListCmd) Run(out *output.Writer) error {
4249 return out .WriteFiltered (apps , c .Fields )
4350}
4451
52+ // AppsGetCmd is `onecli apps get`.
53+ type AppsGetCmd struct {
54+ Provider string `required:"" help:"Provider name (e.g. 'github', 'gmail')."`
55+ Fields string `optional:"" help:"Comma-separated list of fields to include in output."`
56+ }
57+
58+ func (c * AppsGetCmd ) Run (out * output.Writer ) error {
59+ if err := validate .ResourceID (c .Provider ); err != nil {
60+ return fmt .Errorf ("invalid provider: %w" , err )
61+ }
62+
63+ client , err := newClient ()
64+ if err != nil {
65+ return err
66+ }
67+ app , err := client .GetApp (newContext (), c .Provider )
68+ if err != nil {
69+ return err
70+ }
71+
72+ if app .Hint != "" {
73+ out .SetHint (app .Hint )
74+ app .Hint = ""
75+ }
76+
77+ return out .WriteFiltered (app , c .Fields )
78+ }
79+
4580// AppsConfigureCmd is `onecli apps configure`.
4681type AppsConfigureCmd struct {
4782 Provider string `required:"" help:"Provider name (e.g. 'github', 'gmail')."`
@@ -85,9 +120,18 @@ func (c *AppsConfigureCmd) Run(out *output.Writer) error {
85120 return err
86121 }
87122
88- return out .Write (map [string ]string {
89- "status" : "configured" ,
90- "provider" : c .Provider ,
123+ app , err := client .GetApp (newContext (), c .Provider )
124+ if err != nil {
125+ return err
126+ }
127+
128+ if app .Hint != "" {
129+ out .SetHint (app .Hint )
130+ }
131+
132+ return out .Write (configureResult {
133+ App : c .Provider ,
134+ Status : "configured" ,
91135 })
92136}
93137
0 commit comments