forked from Elara6331/itd
Add resource loading as part of DFU
This commit is contained in:
parent
2d0db1dcf1
commit
f639fef992
@ -11,6 +11,19 @@ import (
|
||||
)
|
||||
|
||||
func fwUpgrade(c *cli.Context) error {
|
||||
resources := c.String("resources")
|
||||
if resources != "" {
|
||||
absRes, err := filepath.Abs(resources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = resLoad(c.Context, []string{absRes})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
var upgType api.UpgradeType
|
||||
|
@ -143,6 +143,11 @@ func main() {
|
||||
Aliases: []string{"f"},
|
||||
Usage: "Path to firmware image (.bin file)",
|
||||
},
|
||||
&cli.PathFlag{
|
||||
Name: "resources",
|
||||
Aliases: []string{"r"},
|
||||
Usage: "Path to resources file (.zip file)",
|
||||
},
|
||||
&cli.PathFlag{
|
||||
Name: "archive",
|
||||
Aliases: []string{"a"},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cheggaaa/pb/v3"
|
||||
@ -9,7 +10,11 @@ import (
|
||||
)
|
||||
|
||||
func resourcesLoad(c *cli.Context) error {
|
||||
if c.Args().Len() == 0 {
|
||||
return resLoad(c.Context, c.Args().Slice())
|
||||
}
|
||||
|
||||
func resLoad(ctx context.Context, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return cli.Exit("Command load requires one argument.", 1)
|
||||
}
|
||||
|
||||
@ -19,12 +24,12 @@ func resourcesLoad(c *cli.Context) error {
|
||||
// Start full bar at 0 total
|
||||
bar := pb.ProgressBarTemplate(rmTmpl).Start(0)
|
||||
|
||||
path, err := filepath.Abs(c.Args().Get(0))
|
||||
path, err := filepath.Abs(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progCh, err := client.LoadResources(c.Context, path)
|
||||
progCh, err := client.LoadResources(ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user