Repository: magefile/mage (go)

Issue:
Camel case the commands in listing
I get that this is very subjective, but this is from the Hugo build:

```bash
▶ mage
  check            Run tests and linters
  checkvendor      Verify that vendored packages match git HEAD
  docker           Build hugo Docker container
  fmt              Run gofmt linter
  hugo             Build hugo binary
  hugonogitinfo    Build hugo without git info
  hugorace         Build hugo binary with race detector enabled
  install          Install hugo binary
  lint             Run golint linter
  test             Run tests
  test386          Run tests in 32-bit mode
  testcoverhtml    Generate test coverage report
  testrace         Run tests with race detector
  vendor           Install govendor and sync Hugo's vendored dependencies
  vet              Run go vet linter
```

Which is mostly beautiful. But the all lower-case command names looks "wrong" in my eyes. I would much prefer that it followed the original case of the method, but with a lowercase first letter, so `hugoRace`, `testCoverHTML`etc. I would still expect the all lowercase variant to work.


Pull request:
present the commands in camelCase - fixes #37

Patch:
diff --git a/mage/main.go b/mage/main.go
index 8a0253c..c7eb170 100644
--- a/mage/main.go
+++ b/mage/main.go
@@ -15,6 +15,7 @@ import (
 	"strings"
 	"syscall"
 	"text/template"
+	"unicode"
 
 	"github.com/magefile/mage/build"
 	"github.com/magefile/mage/mg"
@@ -27,6 +28,10 @@ const mageVer = "v0.3"
 
 var output = template.Must(template.New("").Funcs(map[string]interface{}{
 	"lower": strings.ToLower,
+	"lowerfirst": func(s string) string {
+		r := []rune(s)
+		return string(unicode.ToLower(r[0])) + string(r[1:])
+	},
 }).Parse(tpl))
 var initOutput = template.Must(template.New("").Parse(mageTpl))
 
diff --git a/mage/template.go b/mage/template.go
index 1115c0e..b8f7b62 100644
--- a/mage/template.go
+++ b/mage/template.go
@@ -97,7 +97,7 @@ func list() error {
 	w := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0)
 	log.Println("Targets: ")
 	{{- range .Funcs}}
-	fmt.Fprintln(w, "  {{lower .Name}}{{if eq .Name $default}}*{{end}}\t{{.Synopsis}}")
+	fmt.Fprintln(w, "  {{lowerfirst .Name}}{{if eq .Name $default}}*{{end}}\t{{.Synopsis}}")
 	{{- end}}
 	err := w.Flush()
 	{{- if .Default}}


Test patch:
diff --git a/mage/main_test.go b/mage/main_test.go
index b2c6a11..e3f5925 100644
--- a/mage/main_test.go
+++ b/mage/main_test.go
@@ -75,6 +75,47 @@ func TestVerbose(t *testing.T) {
 	}
 }
 
+func TestGoRunList(t *testing.T) {
+	c := exec.Command("go", "run", "main.go", "-l")
+	c.Dir = "./testdata"
+	c.Env = os.Environ()
+	b, err := c.CombinedOutput()
+	if err != nil {
+		t.Error("error:", err)
+	}
+	actual := string(b)
+	expected := `Targets: 
+  panics                Function that panics.
+  panicsErr             Error function that panics.
+  returnsError*         Synopsis for returns error.
+  returnsNonNilError    Returns a non-nil error.
+  returnsVoid           
+  testVerbose           
+
+* default target
+`
+	if actual != expected {
+		t.Fatalf("expected %q, but got %q", expected, actual)
+	}
+}
+
+func TestGoRunListNoDefault(t *testing.T) {
+	c := exec.Command("go", "run", "main.go")
+	c.Dir = "./testdata/no_default"
+	c.Env = os.Environ()
+	b, err := c.CombinedOutput()
+	if err != nil {
+		t.Error("error:", err)
+	}
+	actual := string(b)
+	expected := `  bazBuz    Prints out 'BazBuz'.
+  fooBar    Prints out 'FooBar'.
+`
+	if actual != expected {
+		t.Fatalf("expected %q, but got %q", expected, actual)
+	}
+}
+
 func TestGoRunError(t *testing.T) {
 	c := exec.Command("go", "run", "main.go", "returnsnonnilerror")
 	c.Dir = "./testdata"
diff --git a/mage/testdata/no_default/magefile.go b/mage/testdata/no_default/magefile.go
new file mode 100644
index 0000000..1c440bf
--- /dev/null
+++ b/mage/testdata/no_default/magefile.go
@@ -0,0 +1,19 @@
+// +build mage
+
+package main
+
+import (
+	"fmt"
+)
+
+// No default so we can check the list().
+
+// Prints out 'FooBar'.
+func FooBar() {
+	fmt.Println("FooBar")
+}
+
+// Prints out 'BazBuz'.
+func BazBuz() {
+	fmt.Println("BazBuz")
+}
diff --git a/mage/testdata/no_default/main.go b/mage/testdata/no_default/main.go
new file mode 100644
index 0000000..a3f23b4
--- /dev/null
+++ b/mage/testdata/no_default/main.go
@@ -0,0 +1,13 @@
+// +build ignore
+
+package main
+
+import (
+	"os"
+
+	"github.com/magefile/mage/mage"
+)
+
+func main() {
+	os.Exit(mage.Main())
+}