start undocker
This commit is contained in:
commit
0f883d49e7
15
BUILD
Normal file
15
BUILD
Normal file
@ -0,0 +1,15 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "undocker_lib",
|
||||
srcs = ["main.go"],
|
||||
importpath = "github.com/motiejus/code/undocker",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["@com_github_jessevdk_go_flags//:go-flags"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "undocker",
|
||||
embed = [":undocker_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
39
main.go
Normal file
39
main.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"errors"
|
||||
|
||||
goflags "github.com/jessevdk/go-flags"
|
||||
)
|
||||
|
||||
type opts struct {
|
||||
PositionalArgs struct {
|
||||
Infile goflags.Filename `long:"infile" description:"Docker container tarball"`
|
||||
Outfile string `long:"outfile" description:"Output tarball"`
|
||||
} `positional-args:"yes" required:"yes"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := run(os.Args); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func run(args []string) error {
|
||||
var flags opts
|
||||
args1, err := goflags.ParseArgs(&flags, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(args1) != 0 {
|
||||
return errors.New("too many args")
|
||||
}
|
||||
|
||||
fmt.Printf("infile: %s\n", flags.PositionalArgs.Infile)
|
||||
fmt.Printf("outfile: %s\n", flags.PositionalArgs.Outfile)
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user