-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
200 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Autocompletion | ||
|
||
Alfons 5.2 introduced dynamic shell autocompletion. That means that on most shells (but especially Zsh), you will get completions for tasks, task options and maybe even task values. | ||
|
||
## Bash | ||
|
||
The Bash completion script is very poor. This is because Bash's autocompletion is very poor. It will list the available tasks, and if it can detect a task, also suggest the options for that task. | ||
|
||
### Installing | ||
|
||
``` | ||
# cp bin/completion.bash /etc/bash_completion.d/alfons | ||
``` | ||
|
||
## Zsh | ||
|
||
Zsh will autocomplete tasks, task options, and for certain task options, also suggest values. | ||
|
||
If a task option has a value of `<file>`, `<user>`, `<group>` or `<path>`, it will use Zsh's internal resolvers to complete suggestions. | ||
|
||
### Installing | ||
|
||
Move the completion file to anywhere in your `$FPATH`. | ||
|
||
```sh | ||
# Oh my Zsh! | ||
$ cp bin/completion.zsh $HOME/.oh-my-zsh/completions/_alfons | ||
# Hopefully cross platform | ||
$ sudo cp bin/completion.zsh /usr/share/zsh/functions/Completion/_alfons | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Documenting | ||
|
||
In Alfons 5.2, a new feature was implemented to document your own Taskfiles. Previously, there was no way to generate a help message, or to have shell completion. Thanks to the docstrings, and a little bit of magic, this is now possible. | ||
|
||
## Docstrings | ||
|
||
Docstrings are comments in the Taskfile that begin with `---`. These are followed by a tag (`@task`, `@argument`, `@flag`) that determines how the rest of the comment will be parsed. | ||
|
||
The docstrings are untied from the actual code since it needs to be language-agnostic, and there are many ways within a single language to define tasks. As such, the tasks displayed in the new help message are a mix between documented tasks, and undocumented tasks read from the Taskfile. | ||
|
||
## Declaring a task | ||
|
||
`--- @task name Description of the task.` | ||
|
||
A task is declared using the docstring above. | ||
|
||
## Declaring an option for a task | ||
|
||
`--- @option task [long s] <value> Description of the option.` | ||
|
||
The docstring above has several parts. First, the name of the task that you are referencing. Then, between square brackets, you have to put all the forms of the option, the long preferrably first. Between the angle brackets, you can put each of the expected values. Everything that comes afterward is the description of the option. | ||
|
||
## Flagging | ||
|
||
`--- @flag * hide` | ||
`--- @flag task hide` | ||
|
||
As of right now, the only flag available is `hide`, which makes either all tasks (`*`) or a task invisible to autocompletion and the help message. |
Oops, something went wrong.