diff --git a/autocomplete.zsh b/autocomplete.zsh new file mode 100644 index 0000000..73b56e8 --- /dev/null +++ b/autocomplete.zsh @@ -0,0 +1,33 @@ +# Invoke tab-completion script to be sourced with the Z shell. +# Known to work on zsh 5.0.x, probably works on later 4.x releases as well (as +# it uses the older compctl completion system). + +_complete_invoke() { + # `words` contains the entire command string up til now (including + # program name). + # + # We hand it to Invoke so it can figure out the current context: spit back + # core options, task names, the current task's options, or some combo. + # + # Before doing so, we attempt to tease out any collection flag+arg so we + # can ensure it is applied correctly. + collection_arg='' + if [[ "${words}" =~ "(-c|--collection) [^ ]+" ]]; then + collection_arg=$MATCH + fi + # `reply` is the array of valid completions handed back to `compctl`. + # Use ${=...} to force whitespace splitting in expansion of + # $collection_arg + reply=( $(invoke ${=collection_arg} --complete -- ${words}) ) +} + + +# Tell shell builtin to use the above for completing our given binary name(s). +# * -K: use given function name to generate completions. +# * +: specifies 'alternative' completion, where options after the '+' are only +# used if the completion from the options before the '+' result in no matches. +# * -f: when function generates no results, use filenames. +# * positional args: program names to complete for. +compctl -K _complete_invoke + -f invoke inv + +# vim: set ft=sh : diff --git a/main.py b/main.py index ee60be1..353238f 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,22 @@ +from celery import Celery from fastapi import FastAPI app = FastAPI() +celery = Celery( + __name__, broker="redis://127.0.0.1:6379/0", backend="redis://127.0.0.1:6379/0" +) + + @app.get("/") async def root(): return {"message": "Hello World"} + + +@celery.task +def divide(x, y): + import time + + time.sleep(5) + return x / y diff --git a/tasks.py b/tasks.py index bcff483..46da6f7 100644 --- a/tasks.py +++ b/tasks.py @@ -7,7 +7,8 @@ from invoke import task @task def start_app(c): """Starts the app.""" - print("Start the app") + print("Starting the developer environment...") + start_redis(c) c.run("uvicorn main:app --reload", pty=True)