[PD1] Fix adding user cert to db, also finished logs
This commit is contained in:
parent
f2118fe570
commit
4ea8315aed
4 changed files with 24 additions and 16 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"errors"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
)
|
||||
|
@ -30,8 +31,10 @@ func Run() {
|
|||
command := flag.Arg(0)
|
||||
switch command {
|
||||
case "send":
|
||||
if flag.NArg() < 3 {
|
||||
log.Fatalln("Insufficient arguments for 'send' command. Usage: send <UID> <SUBJECT>")
|
||||
if flag.NArg() != 3 {
|
||||
printError("MSG SERVICE: command error!")
|
||||
showHelp()
|
||||
os.Exit(1)
|
||||
}
|
||||
uid := flag.Arg(1)
|
||||
plainSubject := flag.Arg(2)
|
||||
|
@ -42,6 +45,11 @@ func Run() {
|
|||
}
|
||||
|
||||
case "askqueue":
|
||||
if flag.NArg() > 3 {
|
||||
printError("MSG SERVICE: command error!")
|
||||
showHelp()
|
||||
os.Exit(1)
|
||||
}
|
||||
pageInput := flag.Arg(1)
|
||||
page := 1
|
||||
if pageInput != "" {
|
||||
|
@ -64,7 +72,9 @@ func Run() {
|
|||
|
||||
case "getmsg":
|
||||
if flag.NArg() < 2 {
|
||||
log.Fatalln("Insufficient arguments for 'getmsg' command. Usage: getmsg <NUM>")
|
||||
printError("MSG SERVICE: command error!")
|
||||
showHelp()
|
||||
os.Exit(1)
|
||||
}
|
||||
numString := flag.Arg(1)
|
||||
num, err := strconv.Atoi(numString)
|
||||
|
@ -73,14 +83,15 @@ func Run() {
|
|||
}
|
||||
err = getMsgCommand(clientKeyStore, num)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
printError(err.Error())
|
||||
}
|
||||
|
||||
case "help":
|
||||
showHelp()
|
||||
|
||||
default:
|
||||
commandError()
|
||||
printError("MSG SERVICE: command error!")
|
||||
showHelp()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package client
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
@ -15,9 +14,8 @@ func readStdin(message string) string {
|
|||
return scanner.Text()
|
||||
}
|
||||
|
||||
func commandError() {
|
||||
fmt.Println("MSG SERVICE: command error!")
|
||||
showHelp()
|
||||
func printError(err string) {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
|
||||
func showHelp() {
|
||||
|
@ -37,7 +35,7 @@ func showMessagesInfo(page int, numPages int, messages []ClientMessageInfo) int
|
|||
for _, message := range messages {
|
||||
if message.decryptError != nil {
|
||||
fmt.Printf("ERROR: %v:%v:%v:", message.Num, message.FromUID, message.Timestamp)
|
||||
log.Println(message.decryptError)
|
||||
fmt.Println(message.decryptError)
|
||||
} else {
|
||||
fmt.Printf("%v:%v:%v:%v\n", message.Num, message.FromUID, message.Timestamp, message.Subject)
|
||||
}
|
||||
|
@ -52,7 +50,7 @@ func messagesInfoPageNavigation(page int, numPages int) int {
|
|||
switch page {
|
||||
case 1:
|
||||
if page == numPages {
|
||||
action = readStdin("Actions: quit")
|
||||
return 0
|
||||
} else {
|
||||
action = readStdin("Actions: quit/next")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue