From 13ab26491b9862fce2da0ba4f526dbae59cb9cdb Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Mon, 26 Feb 2018 19:58:28 -0800 Subject: [PATCH] Stub out pm package create --- cmd/pm/main.go | 29 +++++++++++++++++++++++++++++ pkg/pkg.go | 8 ++++++++ 2 files changed, 37 insertions(+) create mode 100644 pkg/pkg.go diff --git a/cmd/pm/main.go b/cmd/pm/main.go index 513c002..53ecc96 100644 --- a/cmd/pm/main.go +++ b/cmd/pm/main.go @@ -6,6 +6,7 @@ import ( "os" "mcquay.me/pm/keyring" + "mcquay.me/pm/pkg" ) const usage = `pm: simple, cross-platform system package manager @@ -13,6 +14,7 @@ const usage = `pm: simple, cross-platform system package manager subcommands: environ (env) -- print environment information keyring (key) -- interact with pm's OpenPGP keyring + package (pkg) -- create packages ` const keyUsage = `pm keyring: interact with pm's OpenPGP keyring @@ -27,6 +29,12 @@ subcommands: verify (v) -- verify a detached signature ` +const pkgUsage = `pm package: generate pm-compatible packages + +subcommands: + create (c) -- create a fresh keypair +` + func main() { if len(os.Args) < 2 { fatalf("pm: missing subcommand\n\n%v", usage) @@ -130,6 +138,27 @@ func main() { default: fatalf("unknown keyring subcommand: %q\n\nusage: %v", sub, keyUsage) } + case "package", "pkg": + if len(os.Args[1:]) < 2 { + fatalf("pm package: insufficient args\n\nusage: %v", pkgUsage) + } + sub := os.Args[2] + switch sub { + case "create", "creat", "c": + if signID == "" { + fatalf("must set PM_PGP_ID\n") + } + args := os.Args[3:] + if len(args) != 1 { + fatalf("usage: pm package create \n") + } + dir := args[0] + if err := pkg.Create(dir, signID); err != nil { + fatalf("creating package: %v\n", err) + } + default: + fatalf("unknown package subcommand: %q\n\nusage: %v", sub, pkgUsage) + } default: fatalf("uknown subcommand %q\n\nusage: %v", cmd, usage) } diff --git a/pkg/pkg.go b/pkg/pkg.go new file mode 100644 index 0000000..16ef817 --- /dev/null +++ b/pkg/pkg.go @@ -0,0 +1,8 @@ +package pkg + +import "fmt" + +// Create traverses the contents of dir and emits a valid pkg, signed by id +func Create(dir, id string) error { + return fmt.Errorf("creating package from %q for %q: NYI", dir, id) +}