add --list (or -l) flag to print existing tasks

If an inexixtent task is given, the help also prints as before

Also fixing README documentation

Closes #51
This commit is contained in:
Andrey Nering
2017-07-15 14:09:27 -03:00
parent e781ac2512
commit 998935ea55
4 changed files with 16 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ var (
version = "master"
)
const usage = `Usage: task [-ifwv] [--init] [--force] [--watch] [--verbose] [task...]
const usage = `Usage: task [-ilfwv] [--init] [--list] [--force] [--watch] [--verbose] [task...]
Runs the specified task(s). Falls back to the "default" task if no task name
was specified, or lists all tasks if an unknown task name was specified.
@@ -45,6 +45,7 @@ func main() {
var (
versionFlag bool
init bool
list bool
force bool
watch bool
verbose bool
@@ -52,6 +53,7 @@ func main() {
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder")
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
pflag.BoolVarP(&force, "force", "f", false, "forces execution even when the task is up-to-date")
pflag.BoolVarP(&watch, "watch", "w", false, "enables watch of the given task")
pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode")
@@ -86,6 +88,11 @@ func main() {
log.Fatal(err)
}
if list {
e.PrintTasksHelp()
return
}
args := pflag.Args()
if len(args) == 0 {
log.Println("task: No argument given, trying default task")