@@ -10,30 +10,18 @@ import (
10
10
"gopkg.in/yaml.v3"
11
11
)
12
12
13
- func formatOtaByIdOutput (wideOutput bool , st * otaapi.OtaStatusPrint ) {
14
- if ! wideOutput {
15
- st .Ota .DeviceID = ""
16
- st .Ota .ErrorReason = ""
17
- st .Ota .Sha256 = ""
18
- }
19
- printOut (st , wideOutput )
13
+ func formatOtaByIdOutput ( st * otaapi.OtaStatusPrint ) {
14
+ printOut (st )
20
15
}
21
16
22
- func formatOutputSlice (wideOutput bool , st []otaapi.Ota ) {
17
+ func formatOutputSlice (st []otaapi.Ota ) {
23
18
if st == nil {
24
19
st = []otaapi.Ota {}
25
20
}
26
- for i := range st {
27
- if ! wideOutput {
28
- st [i ].DeviceID = ""
29
- st [i ].ErrorReason = ""
30
- st [i ].Sha256 = ""
31
- }
32
- }
33
- printOut (st , wideOutput )
21
+ printOut (st )
34
22
}
35
23
36
- func printOut (res any , wideOutput bool ) {
24
+ func printOut (res any ) {
37
25
outputformat := feedback .GetFormat ()
38
26
if outputformat == feedback .JSON || outputformat == feedback .JSONMini {
39
27
jsonRes , _ := json .MarshalIndent (res , "" , " " )
@@ -59,37 +47,24 @@ func printOut(res any, wideOutput bool) {
59
47
if st , ok := res .([]otaapi.Ota ); ok {
60
48
61
49
for i := range st {
62
- if i == 0 {
63
- if wideOutput {
64
- fmt .Println (st [i ].GetWideCSVHeader ())
65
- } else {
66
- fmt .Println (st [i ].GetCSVHeader ())
67
- }
68
- }
69
- if wideOutput {
70
- fmt .Println (st [i ].ToWideCSV ())
71
- } else {
72
- fmt .Println (st [i ].ToCSV ())
73
- }
50
+ fmt .Println (st [i ].ToLine ())
74
51
}
75
52
}
76
53
}
77
54
}
78
55
79
- func PrintOtaStatus (otaid , device , otaidpath string , wideOutput bool , cred * config.Credentials ) error {
56
+ func PrintOtaStatus (otaid , device string , cred * config.Credentials ) error {
80
57
81
58
if feedback .GetFormat () == feedback .JSONMini {
82
59
return fmt .Errorf ("jsonmini format is not supported for this command" )
83
60
}
84
61
85
62
otapi := otaapi .NewClient (cred )
86
63
87
- if otaidpath != "" {
88
- // TODO: implement
89
- } else if otaid != "" {
64
+ if otaid != "" {
90
65
res , err := otapi .GetOtaStatusByOtaID (otaid )
91
66
if err == nil && res != nil {
92
- formatOtaByIdOutput (wideOutput , & otaapi.OtaStatusPrint {
67
+ formatOtaByIdOutput (& otaapi.OtaStatusPrint {
93
68
Ota : res .Ota ,
94
69
Details : res .States ,
95
70
})
@@ -99,7 +74,7 @@ func PrintOtaStatus(otaid, device, otaidpath string, wideOutput bool, cred *conf
99
74
} else if device != "" {
100
75
res , err := otapi .GetOtaStatusByDeviceID (device )
101
76
if err == nil && res != nil {
102
- formatOutputSlice (wideOutput , res .Ota )
77
+ formatOutputSlice (res .Ota )
103
78
} else if err != nil {
104
79
return err
105
80
}
0 commit comments