Add resource loading to ITD #28

Merged
Elara6331 merged 5 commits from resource-loading into master 2022-10-16 20:17:50 +00:00
3 changed files with 26 additions and 3 deletions
Showing only changes of commit f639fef992 - Show all commits

View File

@ -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

View File

@ -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"},

View File

@ -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
}