@@ -22,6 +22,11 @@ func getVaultsHandler(cmd *cobra.Command) VaultsCmd {
2222 return VaultsCmd {vaults : & client .Vaults , prompter : interactive .NewPrompter (), openURL : browser .OpenURL }
2323}
2424
25+ func addVaultJSONOutputFlag (cmd * cobra.Command ) {
26+ addJSONOutputFlag (cmd )
27+ cmd .Flags ().Lookup ("output" ).Usage = "Output format: json for display-safe API fields"
28+ }
29+
2530func vaultOutput (cmd * cobra.Command ) string {
2631 output , _ := cmd .Flags ().GetString ("output" )
2732 return output
@@ -78,7 +83,7 @@ JSON output preserves returned public fields but omits unknown/opaque provider d
7883 }}
7984 create .Flags ().String ("name" , "" , "Immutable vault name (required)" )
8085 _ = create .MarkFlagRequired ("name" )
81- addJSONOutputFlag (create )
86+ addVaultJSONOutputFlag (create )
8287
8388 list := & cobra.Command {Use : "list" , Short : "List vaults in the selected project" , Args : cobra .NoArgs , PreRunE : vaultPreRun ,
8489 RunE : func (cmd * cobra.Command , args []string ) error {
@@ -89,21 +94,21 @@ JSON output preserves returned public fields but omits unknown/opaque provider d
8994 }}
9095 list .Flags ().Int64 ("limit" , 20 , "Maximum vaults to return (1-100)" )
9196 list .Flags ().Int64 ("offset" , 0 , "Number of vaults to skip" )
92- addJSONOutputFlag (list )
97+ addVaultJSONOutputFlag (list )
9398
9499 get := & cobra.Command {Use : "get <vault>" , Short : "Get a vault by ID or name" , Args : cobra .ExactArgs (1 ), PreRunE : vaultPreRun ,
95100 RunE : func (cmd * cobra.Command , args []string ) error {
96101 return getVaultsHandler (cmd ).Get (cmd .Context (), args [0 ], vaultOutput (cmd ))
97102 }}
98- addJSONOutputFlag (get )
103+ addVaultJSONOutputFlag (get )
99104 cmd .AddCommand (create , list , get , newVaultDeleteCommand (false ))
100105
101106 items := & cobra.Command {Use : "items" , Short : "Inspect vault item state, actions, aliases, and outcomes" }
102107 itemList := & cobra.Command {Use : "list <vault>" , Short : "List items by vault ID or name" , Args : cobra .ExactArgs (1 ), PreRunE : vaultPreRun ,
103108 RunE : func (cmd * cobra.Command , args []string ) error {
104109 return getVaultsHandler (cmd ).ListItems (cmd .Context (), args [0 ], vaultOutput (cmd ))
105110 }}
106- addJSONOutputFlag (itemList )
111+ addVaultJSONOutputFlag (itemList )
107112 itemGet := & cobra.Command {Use : "get <vault> <key>" , Short : "Get item state and any required action" , Args : cobra .ExactArgs (2 ), PreRunE : vaultPreRun ,
108113 Long : "Get item state, available operations, provider actions, and returned checkout aliases.\n --wait is a single bounded server-side observation, not a retry or a guarantee of readiness.\n An item still pending after the wait is returned as-is; ready does not mean paid." ,
109114 RunE : func (cmd * cobra.Command , args []string ) error {
@@ -115,7 +120,7 @@ JSON output preserves returned public fields but omits unknown/opaque provider d
115120 itemGet .Flags ().Int64 ("wait" , 0 , "Hold while pending for up to this many seconds (0-60); observe only" )
116121 itemGet .Flags ().StringSlice ("expand" , nil , "Advertised live data to fetch: payment_methods" )
117122 itemGet .Flags ().Bool ("open" , false , "Open a returned HTTPS action URL in your browser" )
118- addJSONOutputFlag (itemGet )
123+ addVaultJSONOutputFlag (itemGet )
119124 itemEvents := & cobra.Command {Use : "events <vault> <key>" , Short : "Read immutable item events without retrying payments" , Args : cobra .ExactArgs (2 ), PreRunE : vaultPreRun ,
120125 RunE : func (cmd * cobra.Command , args []string ) error {
121126 after , _ := cmd .Flags ().GetString ("after" )
@@ -124,7 +129,7 @@ JSON output preserves returned public fields but omits unknown/opaque provider d
124129 }}
125130 itemEvents .Flags ().String ("after" , "" , "Return events after this event ID (use the last ID from the previous response)" )
126131 itemEvents .Flags ().Int64 ("wait" , 0 , "Long-poll once for new events (0-60 seconds)" )
127- addJSONOutputFlag (itemEvents )
132+ addVaultJSONOutputFlag (itemEvents )
128133 items .AddCommand (itemList , itemGet , itemEvents , newVaultDeleteCommand (true ))
129134
130135 wallets := & cobra.Command {Use : "wallets" , Short : "Connect provider wallets and inspect funding methods" }
@@ -140,13 +145,13 @@ JSON output preserves returned public fields but omits unknown/opaque provider d
140145 _ = walletCreate .MarkFlagRequired ("provider" )
141146 walletCreate .Flags ().String ("user-id" , "" , "Already enrolled AgentCard user ID in this organization (optional)" )
142147 walletCreate .Flags ().Bool ("open" , false , "Open the returned HTTPS connection/enrollment URL" )
143- addJSONOutputFlag (walletCreate )
148+ addVaultJSONOutputFlag (walletCreate )
144149 methods := & cobra.Command {Use : "payment-methods <vault> <key>" , Short : "Fetch advertised live wallet payment methods" , Args : cobra .ExactArgs (2 ), PreRunE : vaultPreRun ,
145150 Long : "Fetch payment_methods through the item's GET expansion. The wallet must advertise this expansion.\n Displays selectable IDs and advisory capabilities; never automatically chooses a funding method.\n JSON returns the item with expanded.payment_methods, like items get --expand payment_methods." ,
146151 RunE : func (cmd * cobra.Command , args []string ) error {
147152 return getVaultsHandler (cmd ).GetItem (cmd .Context (), args [0 ], args [1 ], 0 , []string {"payment_methods" }, vaultOutput (cmd ), false )
148153 }}
149- addJSONOutputFlag (methods )
154+ addVaultJSONOutputFlag (methods )
150155 wallets .AddCommand (walletCreate , methods )
151156
152157 cards := & cobra.Command {Use : "cards" , Short : "Configure card requests and explicitly authorize requested Link cards" }
@@ -157,7 +162,7 @@ JSON output preserves returned public fields but omits unknown/opaque provider d
157162 return getVaultsHandler (cmd ).Authorize (cmd .Context (), args [0 ], args [1 ], vaultOutput (cmd ), open )
158163 }}
159164 authorize .Flags ().Bool ("open" , false , "Open the returned HTTPS approval URL" )
160- addJSONOutputFlag (authorize )
165+ addVaultJSONOutputFlag (authorize )
161166 cards .AddCommand (newVaultCardCommand (false ), newVaultCardCommand (true ), authorize )
162167 cmd .AddCommand (items , wallets , cards )
163168 return cmd
@@ -196,8 +201,7 @@ Permitted domains come from the provider and cannot be configured by this API.
196201Neither create nor update authorizes a Link card. The API enforces update eligibility,
197202provider/wallet invariants, and immutable item keys. Update replaces the entire spec;
198203optional purchase details set outside the CLI are removed when omitted.
199- Never reconfigure to retry a failed,
200- timed-out, rejected, or indeterminate payment.` ,
204+ Never reconfigure to retry a failed, timed-out, rejected, or indeterminate payment.` ,
201205 RunE : func (cmd * cobra.Command , args []string ) error {
202206 spec , err := vaultCardSpecFromFlags (cmd )
203207 if err != nil {
@@ -220,7 +224,7 @@ timed-out, rejected, or indeterminate payment.`,
220224 cmd .Flags ().Bool ("live" , false , "Request a live Link payment credential (explicit opt-in)" )
221225 cmd .MarkFlagsMutuallyExclusive ("test" , "live" )
222226 cmd .Flags ().String ("card-id" , "" , "AgentCard vaulted card ID; omit to let the cardholder select during approval" )
223- addJSONOutputFlag (cmd )
227+ addVaultJSONOutputFlag (cmd )
224228 return cmd
225229}
226230
0 commit comments