Commit 4764cc44 authored by Tamer Tas's avatar Tamer Tas
Browse files

Improve user interaction messages

parent 2f31025d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import (
	cli "github.com/spf13/cobra"

	"github.com/tmrts/tmplt/pkg/tmplt"
	"github.com/tmrts/tmplt/pkg/util/tlog"
	"github.com/tmrts/tmplt/pkg/util/validate"
)

@@ -15,6 +16,6 @@ var Version = &cli.Command{
	Run: func(_ *cli.Command, args []string) {
		MustValidateArgs(args, []validate.Argument{})

		fmt.Println("Current version is", tmplt.Version)
		tlog.Info(fmt.Sprint("Current version is ", tmplt.Version))
	},
}
+1 −0
Original line number Diff line number Diff line
@@ -10,5 +10,6 @@ func ZipURL(url string) string {
		return url
	}

	// BUG filepath.Join trims slashes use url.Join
	return "https://codeload.github.com/" + url + "/zip/master"
}
+3 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ import (
const (
	// TODO align brackets used in the prompt message
	PromptFormatMessage       = "[?] Please choose a value for %#q [default: %#v]: "
	PromptChoiceFormatMessage = "[?] Please select an option for %#q\n%v  Select from %v..%v [default: %#v]: "
	PromptChoiceFormatMessage = "[?] Please choose an option for %#q\n%v    Select from %v..%v [default: %#v]: "
)

func scanLine() (string, error) {
@@ -156,6 +156,7 @@ func newSlice(name string, choices []string) func() interface{} {
// user input and has a default value that returns result.
func New(name string, defval interface{}) func() interface{} {
	// TODO use reflect package
	// TODO add a prompt as such "How many Items will you enter", "Enter each" use in "{{range Items}}"
	switch defval := defval.(type) {
	case bool:
		return newBool(name, defval)
+2 −0
Original line number Diff line number Diff line
@@ -49,3 +49,5 @@ func Error(msg string) {
func Fatal(msg string) {
	Error(msg)
}

// TODO use dependency injection wrapper for fmt.Print usage in the code base
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ func TestUnixPathPattern(t *testing.T) {
		{"/tmp-dir", true},
		{"/tmp-dir/new_dir", true},
		{"/TMP/dir", true},
		{"rel/dir", true},
	}

	for _, test := range tests {