cli: fix inspect command

There was an empty byte array while trying to restore .nef from bytes
after a34ba92d4.
This commit is contained in:
Anna Shaleva 2020-08-12 12:22:16 +03:00
parent ddf0bfb1ef
commit 478efee0bc

View file

@ -582,15 +582,21 @@ func inspect(ctx *cli.Context) error {
if len(in) == 0 { if len(in) == 0 {
return cli.NewExitError(errNoInput, 1) return cli.NewExitError(errNoInput, 1)
} }
var b []byte var (
var err error b []byte
err error
)
if compile { if compile {
b, err = compiler.Compile(in, nil) b, err = compiler.Compile(in, nil)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1)
} }
} else { } else {
nefFile, err := nef.FileFromBytes(b) f, err := ioutil.ReadFile(in)
if err != nil {
return cli.NewExitError(fmt.Errorf("failed to read .nef file: %w", err), 1)
}
nefFile, err := nef.FileFromBytes(f)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("failed to restore .nef file: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to restore .nef file: %w", err), 1)
} }