changeset 58:ef2697e4490e draft

Add a more detailed usage note, and use logrus Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author yakumo.izuru
date Tue, 18 Apr 2023 12:29:12 +0000
parents 9e556e91fbf6
children ed3aa9aaad0a
files cmd/aya/main.go go.mod go.sum
diffstat 3 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/aya/main.go	Thu Apr 13 23:37:34 2023 +0000
+++ b/cmd/aya/main.go	Tue Apr 18 12:29:12 2023 +0000
@@ -5,7 +5,6 @@
 	"fmt"
 	"io"
 	"io/ioutil"
-	"log"
 	"os"
 	"os/exec"
 	"path/filepath"
@@ -16,6 +15,7 @@
 	"github.com/russross/blackfriday/v2"
 	"gopkg.in/yaml.v2"
 	"marisa.chaotic.ninja/aya"
+	log "github.com/sirupsen/logrus"
 )
 
 const (
@@ -303,10 +303,22 @@
 	os.Setenv("PATH", p)
 }
 
+func printUsage() {
+	fmt.Printf("%v <command> [args]\n", os.Args[0])
+	fmt.Printf("\n")
+	fmt.Printf("Where <command> is:\n")
+	fmt.Printf("\tbuild\tGenerate site\n")
+	fmt.Printf("\twatch\t(Re)generate site while looking for changes\n")
+	fmt.Printf("\tvar\tQuery a variable from a markdown file\n")
+	fmt.Printf("\tversion\tPrint version and exit\n")
+	fmt.Printf("\n")
+	fmt.Printf("Other commands may be dynamically added by plugins found in %v\n", AYADIR)
+	os.Exit(0)
+}
+
 func main() {
 	if len(os.Args) == 1 {
-		fmt.Println(os.Args[0], "<command> [args]")
-		return
+		printUsage()
 	}
 	cmd := os.Args[1]
 	args := os.Args[2:]
--- a/go.mod	Thu Apr 13 23:37:34 2023 +0000
+++ b/go.mod	Tue Apr 18 12:29:12 2023 +0000
@@ -4,5 +4,8 @@
 
 require (
 	github.com/russross/blackfriday/v2 v2.1.0
+	github.com/sirupsen/logrus v1.9.0
 	gopkg.in/yaml.v2 v2.4.0
 )
+
+require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
--- a/go.sum	Thu Apr 13 23:37:34 2023 +0000
+++ b/go.sum	Tue Apr 18 12:29:12 2023 +0000
@@ -1,6 +1,20 @@
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
+github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=