cmdlxcconfig
This commit is contained in:
@@ -9,28 +9,28 @@ import (
|
||||
"go.uber.org/multierr"
|
||||
)
|
||||
|
||||
// CmdRootFS is "rootfs" command
|
||||
type CmdRootFS struct {
|
||||
// Command is "rootfs" command
|
||||
type Command struct {
|
||||
PositionalArgs struct {
|
||||
Infile goflags.Filename `long:"infile" description:"Input tarball"`
|
||||
Outfile string `long:"outfile" description:"Output path, stdout is '-'"`
|
||||
} `positional-args:"yes" required:"yes"`
|
||||
}
|
||||
|
||||
// Execute executes CmdRootFS
|
||||
func (r *CmdRootFS) Execute(args []string) (err error) {
|
||||
// Execute executes rootfs Command
|
||||
func (c *Command) Execute(args []string) (err error) {
|
||||
if len(args) != 0 {
|
||||
return errors.New("too many args")
|
||||
}
|
||||
|
||||
rd, err := os.Open(string(r.PositionalArgs.Infile))
|
||||
rd, err := os.Open(string(c.PositionalArgs.Infile))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { err = multierr.Append(err, rd.Close()) }()
|
||||
|
||||
var out *os.File
|
||||
outf := string(r.PositionalArgs.Outfile)
|
||||
outf := string(c.PositionalArgs.Outfile)
|
||||
if outf == "-" {
|
||||
out = os.Stdout
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user