From 60deeb103e0a3c9d414e71cc47c9adb1d46fe0da Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Mon, 27 Jan 2020 10:05:21 +0100 Subject: [PATCH] cmd/evm: accept --input for disasm command (#20548) --- cmd/evm/disasm.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/evm/disasm.go b/cmd/evm/disasm.go index 69f611e39b..5bc743aa88 100644 --- a/cmd/evm/disasm.go +++ b/cmd/evm/disasm.go @@ -34,17 +34,22 @@ var disasmCommand = cli.Command{ } func disasmCmd(ctx *cli.Context) error { - if len(ctx.Args().First()) == 0 { - return errors.New("filename required") + var in string + switch { + case len(ctx.Args().First()) > 0: + fn := ctx.Args().First() + input, err := ioutil.ReadFile(fn) + if err != nil { + return err + } + in = string(input) + case ctx.GlobalIsSet(InputFlag.Name): + in = ctx.GlobalString(InputFlag.Name) + default: + return errors.New("Missing filename or --input value") } - fn := ctx.Args().First() - in, err := ioutil.ReadFile(fn) - if err != nil { - return err - } - - code := strings.TrimSpace(string(in)) + code := strings.TrimSpace(in) fmt.Printf("%v\n", code) return asm.PrintDisassembled(code) }