Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c34618

Browse files
committedMar 24, 2022
print output in json
1 parent ea0ce60 commit 1c34618

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎cli/keys/generate.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func runGenerateCommand(command *cobra.Command, args []string) {
6161

6262
logrus.Info("Executing `arduino-cli keys generate`")
6363

64-
_, err := keys.Generate(context.Background(), &rpc.KeysGenerateRequest{
64+
resp, err := keys.Generate(context.Background(), &rpc.KeysGenerateRequest{
6565
AlgorithmType: algorithmType,
6666
KeyName: keyName,
6767
KeysKeychain: keysKeychain,
@@ -70,6 +70,19 @@ func runGenerateCommand(command *cobra.Command, args []string) {
7070
feedback.Errorf(tr("Error during Generate: %v"), err)
7171
os.Exit(errorcodes.ErrGeneric)
7272
}
73+
feedback.PrintResult(result{resp})
74+
}
75+
76+
// output from this command requires special formatting, let's create a dedicated
77+
// feedback.Result implementation
78+
type result struct {
79+
Keychain *rpc.KeysGenerateResponse `json:"keys_keychain"`
80+
}
81+
82+
func (dr result) Data() interface{} {
83+
return dr.Keychain
84+
}
7385

74-
feedback.Print(tr("Keys created in: %s", keysKeychain))
86+
func (dr result) String() string {
87+
return (tr("Keys created in: %s", dr.Keychain.KeysKeychain))
7588
}

0 commit comments

Comments
 (0)
Please sign in to comment.