Output errors to STDERR, add description for the usage page, etc

This commit is contained in:
webb 2020-09-04 10:55:35 -04:00
parent b771c1307c
commit 023af72e46
No known key found for this signature in database
GPG Key ID: 8B6F0D2784D22DB2
2 changed files with 8 additions and 6 deletions

11
main.go
View File

@ -3,7 +3,6 @@ package main
import (
"gitea.com/webb/teal"
"github.com/urfave/cli"
"log"
"os"
)
@ -13,14 +12,17 @@ var itCl = teal.Client{
func main() {
cli := &cli.App{
Name: "interrupt",
Usage: "a simple CLI for pxl.blue",
Description: "This is a simple CLI for pxl.blue. You can upload images, get account information and more.",
Commands: []*cli.Command{
{
Name: "upload",
Aliases: []string{"u"},
Usage: "upload a file",
Action: func(c *cli.Context) error {
uploadHandler(c.Args().First())
return nil
err := uploadHandler(c.Args().First())
return err
},
},
{
@ -43,6 +45,7 @@ func main() {
err := cli.Run(os.Args)
if err != nil {
log.Fatal(err)
os.Stderr.WriteString("interrupt: " + err.Error() + "\n")
os.Exit(1)
}
}

View File

@ -9,8 +9,7 @@ import (
func uploadHandler(a string) error {
uploadKey, err := getUploadKey()
if err != nil {
fmt.Println(err)
os.Exit(1)
return err
}
var reader io.Reader