task.fish

 1set -l GO_TASK_PROGNAME task
 2
 3function __task_get_tasks --description "Prints all available tasks with their description" --inherit-variable GO_TASK_PROGNAME
 4  # Check if the global task is requested
 5  set -l global_task false
 6  commandline --current-process | read --tokenize --list --local cmd_args
 7  for arg in $cmd_args
 8    if test "_$arg" = "_--"
 9      break # ignore arguments to be passed to the task
10    end
11    if test "_$arg" = "_--global" -o "_$arg" = "_-g"
12      set global_task true
13      break
14    end
15  end
16
17  # Read the list of tasks (and potential errors)
18  if $global_task
19    $GO_TASK_PROGNAME --global --list-all
20  else
21    $GO_TASK_PROGNAME --list-all
22  end 2>&1 | read -lz rawOutput
23
24  # Return on non-zero exit code (for cases when there is no Taskfile found or etc.)
25  if test $status -ne 0
26    return
27  end
28
29  # Grab names and descriptions (if any) of the tasks
30  set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(\(aliases.*\))/\1\t\2\t\3/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0)
31  if test $output
32    echo $output
33  end
34end
35
36complete -c $GO_TASK_PROGNAME -d '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
37specified.' -xa "(__task_get_tasks)"
38
39complete -c $GO_TASK_PROGNAME -s c -l color     -d 'colored output (default true)'
40complete -c $GO_TASK_PROGNAME -s d -l dir       -d 'sets directory of execution'
41complete -c $GO_TASK_PROGNAME      -l dry       -d 'compiles and prints tasks in the order that they would be run, without executing them'
42complete -c $GO_TASK_PROGNAME -s f -l force     -d 'forces execution even when the task is up-to-date'
43complete -c $GO_TASK_PROGNAME -s h -l help      -d 'shows Task usage'
44complete -c $GO_TASK_PROGNAME -s i -l init      -d 'creates a new Taskfile.yml in the current folder'
45complete -c $GO_TASK_PROGNAME -s l -l list      -d 'lists tasks with description of current Taskfile'
46complete -c $GO_TASK_PROGNAME -s o -l output    -d 'sets output style: [interleaved|group|prefixed]' -xa "interleaved group prefixed"
47complete -c $GO_TASK_PROGNAME -s p -l parallel  -d 'executes tasks provided on command line in parallel'
48complete -c $GO_TASK_PROGNAME -s s -l silent    -d 'disables echoing'
49complete -c $GO_TASK_PROGNAME      -l status    -d 'exits with non-zero exit code if any of the given tasks is not up-to-date'
50complete -c $GO_TASK_PROGNAME      -l summary   -d 'show summary about a task'
51complete -c $GO_TASK_PROGNAME -s t -l taskfile  -d 'choose which Taskfile to run. Defaults to "Taskfile.yml"'
52complete -c $GO_TASK_PROGNAME -s v -l verbose   -d 'enables verbose mode'
53complete -c $GO_TASK_PROGNAME      -l version   -d 'show Task version'
54complete -c $GO_TASK_PROGNAME -s w -l watch     -d 'enables watch of the given task'
55