cmdlxcconfig

This commit is contained in:
2021-05-24 00:11:58 +03:00
parent 890d99cd3e
commit a333fb34ef
5 changed files with 68 additions and 10 deletions

View File

@@ -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 {