Skip to content

Commit

Permalink
add cli edit command
Browse files Browse the repository at this point in the history
  • Loading branch information
pivilartisant committed Jul 25, 2024
1 parent c75b2fb commit 8b1fbe8
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (

func main() {
app := &cli.App{
Name: "Massa's Great DeWEB CLI",
Name: "DeWeb CLI",
Usage: "CLI app for deploying websites",
UsageText: "U_ia pload, delete & edit DeWeb site from the terminal",
UsageText: "Upload, delete & edit DeWeb site from the terminal",
Version: config.Version,
Action: func(cCtx *cli.Context) error {
cli.ShowAppHelp(cCtx)

Check failure on line 23 in cmd/cli/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `cli.ShowAppHelp` is not checked (errcheck)
Expand Down Expand Up @@ -54,6 +54,49 @@ func main() {
return nil
},
},
{
Name: "edit",
Aliases: []string{"e"},
Usage: "Edit website bytecode",
ArgsUsage: "<wallet nickname> <sc address> <website zip file path>",
Action: func(cCtx *cli.Context) error {

if cCtx.Args().Get(0) == "" {
return fmt.Errorf("wallet nickname is required")
}

nickname := cCtx.Args().Get(0)

config := pkgConfig.DefaultConfig(nickname, "https://buildnet.massa.net/api/v2")

if cCtx.Args().Get(1) == "" {
return fmt.Errorf("sc is required")
}

address := cCtx.Args().Get(1)

if cCtx.Args().Get(2) == "" {
return fmt.Errorf("website zip path is required")
}

zipPath := cCtx.Args().Get(2)

bytecode, err := processFileForUpload(zipPath)

if err != nil {
logger.Fatalf("failed to process file for upload: %v", err)
}

err = uploadChunks(bytecode, address, config)
if err != nil {
logger.Fatalf("failed to upload chunks: %v", err)
}

logger.Infof("Website bytecode updated successfully at address: %s", address)

return nil
},
},
},
}

Expand Down

0 comments on commit 8b1fbe8

Please sign in to comment.