From 92b937936ecc01451de1cde4bc1e6590c5d879bf Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Wed, 28 Feb 2018 20:00:25 -0800 Subject: [PATCH] Stub in the commands --- cmd/pm/main.go | 33 +++++++++++++++++++++++++++++++++ remote/remote.go | 21 +++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 remote/remote.go diff --git a/cmd/pm/main.go b/cmd/pm/main.go index 94a0d9e..5d5895e 100644 --- a/cmd/pm/main.go +++ b/cmd/pm/main.go @@ -7,6 +7,7 @@ import ( "mcquay.me/pm/keyring" "mcquay.me/pm/pkg" + "mcquay.me/pm/remote" ) const usage = `pm: simple, cross-platform system package manager @@ -14,6 +15,7 @@ const usage = `pm: simple, cross-platform system package manager subcommands: environ (env) -- print environment information keyring (key) -- interact with pm's OpenPGP keyring + remote -- configure remote pmd servers package (pkg) -- create packages ` @@ -35,6 +37,14 @@ subcommands: create (c) -- create a fresh keypair ` +const remoteUsage = `pm remote: configure remote pmd servers + +subcommands: + add (a) -- add a URI + ls -- list configured remotes + rm -- remove a URI +` + func main() { if len(os.Args) < 2 { fatalf("pm: missing subcommand\n\n%v", usage) @@ -163,6 +173,29 @@ func main() { default: fatalf("unknown package subcommand: %q\n\nusage: %v", sub, pkgUsage) } + case "remote": + if len(os.Args[1:]) < 2 { + fatalf("pm remote: insufficient args\n\nusage: %v", remoteUsage) + } + sub := os.Args[2] + args := os.Args[3:] + + switch sub { + case "add", "a": + if err := remote.Add(root, args); err != nil { + fatalf("remote add: %v\n", err) + } + case "rm": + if err := remote.Remove(root, args); err != nil { + fatalf("remote remove: %v\n", err) + } + case "ls": + if err := remote.List(root, os.Stdout); err != nil { + fatalf("list: %v\n", err) + } + default: + fatalf("unknown package subcommand: %q\n\nusage: %v", sub, remoteUsage) + } default: fatalf("uknown subcommand %q\n\nusage: %v", cmd, usage) } diff --git a/remote/remote.go b/remote/remote.go new file mode 100644 index 0000000..8ca1cd7 --- /dev/null +++ b/remote/remote.go @@ -0,0 +1,21 @@ +package remote + +import ( + "errors" + "io" +) + +// Add appends the provided uri to the list of configured remotes. +func Add(root string, uri []string) error { + return errors.New("NYI") +} + +// Add removes the given uri from the list of configured remotes. +func Remove(root string, uri []string) error { + return errors.New("NYI") +} + +// List prints all configured remotes to w. +func List(root string, w io.Writer) error { + return errors.New("NYI") +}