changeset 17:342f63116bfd

Move commands to canonical Go locations, so go install works.
author Paul Fisher <paul@pfish.zone>
date Fri, 30 Oct 2015 00:18:13 -0400
parents bfc035bd5132
children 00d30c67b56d
files cmds/multipass-add/add.go cmds/multipass-checkpassword/checkpassword.go cmds/multipass-remove/remove.go multipass-add.go multipass-checkpassword.go multipass-remove.go
diffstat 6 files changed, 137 insertions(+), 137 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmds/multipass-add/add.go	Fri Oct 30 00:18:13 2015 -0400
@@ -0,0 +1,40 @@
+// multipass-add allows a user to add an entry to their multipass database.
+
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"os"
+
+	"pfish.zone/go/multipass/auth"
+	"pfish.zone/go/multipass/file"
+)
+
+func main() {
+	passfile, err := file.ForMe()
+	if err != nil {
+		fmt.Println(err.Error())
+		os.Exit(1)
+	}
+	reader := bufio.NewReader(os.Stdin)
+	fmt.Print("Describe password: ")
+	text, err := reader.ReadString('\n')
+	if err != nil {
+		fmt.Println(err.Error())
+		os.Exit(1)
+	}
+	text = text[:len(text)-1]
+	entry, password, err := auth.NewEntry(text)
+	if err != nil {
+		fmt.Println(err.Error())
+		os.Exit(1)
+	}
+	err = passfile.Add(entry)
+	if err != nil {
+		fmt.Println("Couldn't create a password:")
+		fmt.Println(err.Error())
+		os.Exit(1)
+	}
+	fmt.Printf("New password: %s\n", password)
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmds/multipass-checkpassword/checkpassword.go	Fri Oct 30 00:18:13 2015 -0400
@@ -0,0 +1,49 @@
+package main
+
+import (
+	"bufio"
+	"os"
+	"os/user"
+	"syscall"
+
+	"pfish.zone/go/multipass/file"
+)
+
+const (
+	InternalError = 111
+	Failed        = 1
+)
+
+func main() {
+	infile := os.NewFile(3, "")
+	reader := bufio.NewReader(infile)
+	username, err := reader.ReadString(0)
+	if err != nil {
+		os.Exit(InternalError)
+	}
+	username = username[:len(username)-1]
+	pass, err := reader.ReadString(0)
+	if err != nil {
+		os.Exit(InternalError)
+	}
+	pass = pass[:len(pass)-1]
+	infile.Close()
+	passfile, err := file.ForUser(username)
+	if err != nil {
+		os.Exit(Failed)
+	}
+	success, _ := passfile.Authenticate(pass)
+	if !success {
+		os.Exit(Failed)
+	}
+	user, err := user.Lookup(username)
+	if err != nil {
+		os.Exit(Failed)
+	}
+	os.Setenv("USER", user.Username)
+	os.Setenv("HOME", user.HomeDir)
+	os.Setenv("userdb_uid", user.Uid)
+	os.Setenv("userdb_gid", user.Gid)
+	os.Setenv("EXTRA", "userdb_uid userdb_gid")
+	syscall.Exec(os.Args[1], os.Args[1:], os.Environ())
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmds/multipass-remove/remove.go	Fri Oct 30 00:18:13 2015 -0400
@@ -0,0 +1,48 @@
+// multipass-remove allows a user to remove an entry from their multipass database.
+
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"os"
+	"strconv"
+
+	"pfish.zone/go/multipass/file"
+)
+
+func main() {
+	passfile, err := file.ForMe()
+	if err != nil {
+		fmt.Println(err.Error())
+		os.Exit(1)
+	}
+	fmt.Println("Choose a password to remove:")
+	reader := bufio.NewReader(os.Stdin)
+	entries, err := passfile.AllEntries()
+	for i, entry := range entries {
+		fmt.Printf("%2d: %s\n", i+1, entry.Description())
+	}
+	fmt.Print("Enter the number to remove: ")
+	text, err := reader.ReadString('\n')
+	if err != nil {
+		fmt.Println(err.Error())
+		os.Exit(1)
+	}
+	picked, err := strconv.Atoi(text[:len(text)-1])
+	if err != nil {
+		fmt.Println("Not a valid number")
+		os.Exit(1)
+	}
+	picked -= 1
+	if picked < 0 || len(entries) <= picked {
+		fmt.Println("Not a valid selection")
+		os.Exit(1)
+	}
+
+	if err := passfile.Remove(entries[picked].ID()); err != nil {
+		fmt.Printf("Couldn't remove password: %s\n", err.Error())
+		os.Exit(1)
+	}
+	fmt.Println("Removed password entry.")
+}
--- a/multipass-add.go	Fri Oct 30 00:01:59 2015 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-// multipass-add allows a user to add an entry to their multipass database.
-
-package main
-
-import (
-	"bufio"
-	"fmt"
-	"os"
-
-	"pfish.zone/go/multipass/auth"
-	"pfish.zone/go/multipass/file"
-)
-
-func main() {
-	passfile, err := file.ForMe()
-	if err != nil {
-		fmt.Println(err.Error())
-		os.Exit(1)
-	}
-	reader := bufio.NewReader(os.Stdin)
-	fmt.Print("Describe password: ")
-	text, err := reader.ReadString('\n')
-	if err != nil {
-		fmt.Println(err.Error())
-		os.Exit(1)
-	}
-	text = text[:len(text)-1]
-	entry, password, err := auth.NewEntry(text)
-	if err != nil {
-		fmt.Println(err.Error())
-		os.Exit(1)
-	}
-	err = passfile.Add(entry)
-	if err != nil {
-		fmt.Println("Couldn't create a password:")
-		fmt.Println(err.Error())
-		os.Exit(1)
-	}
-	fmt.Printf("New password: %s\n", password)
-}
--- a/multipass-checkpassword.go	Fri Oct 30 00:01:59 2015 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-package main
-
-import (
-	"bufio"
-	"os"
-	"os/user"
-	"syscall"
-
-	"pfish.zone/go/multipass/file"
-)
-
-const (
-	InternalError = 111
-	Failed        = 1
-)
-
-func main() {
-	infile := os.NewFile(3, "")
-	reader := bufio.NewReader(infile)
-	username, err := reader.ReadString(0)
-	if err != nil {
-		os.Exit(InternalError)
-	}
-	username = username[:len(username)-1]
-	pass, err := reader.ReadString(0)
-	if err != nil {
-		os.Exit(InternalError)
-	}
-	pass = pass[:len(pass)-1]
-	infile.Close()
-	passfile, err := file.ForUser(username)
-	if err != nil {
-		os.Exit(Failed)
-	}
-	success, _ := passfile.Authenticate(pass)
-	if !success {
-		os.Exit(Failed)
-	}
-	user, err := user.Lookup(username)
-	if err != nil {
-		os.Exit(Failed)
-	}
-	os.Setenv("USER", user.Username)
-	os.Setenv("HOME", user.HomeDir)
-	os.Setenv("userdb_uid", user.Uid)
-	os.Setenv("userdb_gid", user.Gid)
-	os.Setenv("EXTRA", "userdb_uid userdb_gid")
-	syscall.Exec(os.Args[1], os.Args[1:], os.Environ())
-}
--- a/multipass-remove.go	Fri Oct 30 00:01:59 2015 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-// multipass-remove allows a user to remove an entry from their multipass database.
-
-package main
-
-import (
-	"bufio"
-	"fmt"
-	"os"
-	"strconv"
-
-	"pfish.zone/go/multipass/file"
-)
-
-func main() {
-	passfile, err := file.ForMe()
-	if err != nil {
-		fmt.Println(err.Error())
-		os.Exit(1)
-	}
-	fmt.Println("Choose a password to remove:")
-	reader := bufio.NewReader(os.Stdin)
-	entries, err := passfile.AllEntries()
-	for i, entry := range entries {
-		fmt.Printf("%2d: %s\n", i+1, entry.Description())
-	}
-	fmt.Print("Enter the number to remove: ")
-	text, err := reader.ReadString('\n')
-	if err != nil {
-		fmt.Println(err.Error())
-		os.Exit(1)
-	}
-	picked, err := strconv.Atoi(text[:len(text)-1])
-	if err != nil {
-		fmt.Println("Not a valid number")
-		os.Exit(1)
-	}
-	picked -= 1
-	if picked < 0 || len(entries) <= picked {
-		fmt.Println("Not a valid selection")
-		os.Exit(1)
-	}
-
-	if err := passfile.Remove(entries[picked].ID()); err != nil {
-		fmt.Printf("Couldn't remove password: %s\n", err.Error())
-		os.Exit(1)
-	}
-	fmt.Println("Removed password entry.")
-}