Skip to content

Commit

Permalink
chore: add --json to ipsw ota info cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Aug 7, 2024
1 parent 88ba34c commit aadc3cd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/ipsw/cmd/ota/ota_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ THE SOFTWARE.
package ota

import (
"encoding/json"
"fmt"

"github.com/apex/log"
Expand All @@ -33,6 +34,8 @@ import (

func init() {
OtaCmd.AddCommand(otaInfoCmd)
otaInfoCmd.Flags().BoolP("json", "j", false, "Output as JSON")
viper.BindPFlag("ota.info.json", otaInfoCmd.Flags().Lookup("json"))
}

// otaInfoCmd represents the info command
Expand All @@ -59,9 +62,17 @@ var otaInfoCmd = &cobra.Command{
return fmt.Errorf("failed to get OTA info: %v", err)
}

fmt.Println("\n[OTA Info]")
fmt.Println("==========")
fmt.Println(inf)
if viper.GetBool("ota.info.json") {
dat, err := json.Marshal(inf)
if err != nil {
return fmt.Errorf("failed to marshal OTA info: %v", err)
}
fmt.Println(string(dat))
} else {
fmt.Println("\n[OTA Info]")
fmt.Println("==========")
fmt.Println(inf)
}

return nil

Expand Down

0 comments on commit aadc3cd

Please sign in to comment.