cmd/evm: accept --input for disasm command (#20548)

pull/20595/head
Guillaume Ballet 5 years ago committed by Martin Holst Swende
parent 0b284f6c6c
commit 60deeb103e
  1. 17
      cmd/evm/disasm.go

@ -34,17 +34,22 @@ var disasmCommand = cli.Command{
} }
func disasmCmd(ctx *cli.Context) error { func disasmCmd(ctx *cli.Context) error {
if len(ctx.Args().First()) == 0 { var in string
return errors.New("filename required") switch {
} case len(ctx.Args().First()) > 0:
fn := ctx.Args().First() fn := ctx.Args().First()
in, err := ioutil.ReadFile(fn) input, err := ioutil.ReadFile(fn)
if err != nil { if err != nil {
return err return err
} }
in = string(input)
case ctx.GlobalIsSet(InputFlag.Name):
in = ctx.GlobalString(InputFlag.Name)
default:
return errors.New("Missing filename or --input value")
}
code := strings.TrimSpace(string(in)) code := strings.TrimSpace(in)
fmt.Printf("%v\n", code) fmt.Printf("%v\n", code)
return asm.PrintDisassembled(code) return asm.PrintDisassembled(code)
} }

Loading…
Cancel
Save