Skip to content

Commit

Permalink
cannon: Fix custom --help for multicannon subcommands (#12112)
Browse files Browse the repository at this point in the history
* multicannon: Display custom --help for missing flags

* remove comment
  • Loading branch information
Inphi authored Sep 26, 2024
1 parent 12a38d0 commit 42305d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions cannon/multicannon/load_elf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"fmt"
"os"

"github.com/ethereum-optimism/optimism/cannon/cmd"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
"github.com/urfave/cli/v2"
)

func LoadELF(ctx *cli.Context) error {
if len(os.Args) == 2 && os.Args[2] == "--help" {
if len(os.Args) == 3 && os.Args[2] == "--help" {
if err := list(); err != nil {
return err
}
fmt.Println("use `--type <vm type> --help` to get more detailed help")
return nil
}

typ, err := parseFlag(os.Args[1:], "--type")
Expand All @@ -28,4 +28,10 @@ func LoadELF(ctx *cli.Context) error {
return ExecuteCannon(ctx.Context, os.Args[1:], ver)
}

var LoadELFCommand = cmd.CreateLoadELFCommand(LoadELF)
var LoadELFCommand = &cli.Command{
Name: "load-elf",
Usage: "Load ELF file into Cannon state",
Description: "Load ELF file into Cannon state",
Action: LoadELF,
SkipFlagParsing: true,
}
2 changes: 1 addition & 1 deletion cannon/multicannon/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func Run(ctx *cli.Context) error {
return err
}
fmt.Println("use `--input <valid input file> --help` to get more detailed help")
return nil
}

inputPath, err := parsePathFlag(os.Args[1:], "--input")
Expand All @@ -29,7 +30,6 @@ func Run(ctx *cli.Context) error {
return ExecuteCannon(ctx.Context, os.Args[1:], version)
}

// var RunCommand = cmd.CreateRunCommand(Run)
var RunCommand = &cli.Command{
Name: "run",
Usage: "Run VM step(s) and generate proof data to replicate onchain.",
Expand Down
10 changes: 8 additions & 2 deletions cannon/multicannon/witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/optimism/cannon/cmd"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
)

Expand All @@ -16,6 +15,7 @@ func Witness(ctx *cli.Context) error {
return err
}
fmt.Println("use `--input <valid input file> --help` to get more detailed help")
return nil
}

inputPath, err := parsePathFlag(os.Args[1:], "--input")
Expand All @@ -29,4 +29,10 @@ func Witness(ctx *cli.Context) error {
return ExecuteCannon(ctx.Context, os.Args[1:], version)
}

var WitnessCommand = cmd.CreateWitnessCommand(Witness)
var WitnessCommand = &cli.Command{
Name: "witness",
Usage: "Convert a Cannon JSON state into a binary witness",
Description: "Convert a Cannon JSON state into a binary witness. The hash of the witness is written to stdout",
Action: Witness,
SkipFlagParsing: true,
}

0 comments on commit 42305d8

Please sign in to comment.