Typer
Starter for a Typer CLI app. Base steps come from Python Project Setup.
Create Project Directory
bash
mkdir carbuyers_worker
cd carbuyers_workerAdd Virtual Environment
bash
python3 -m venv .venv
source .venv/bin/activateInstall Typer
bash
pip install typer.gitignore
bash
echo '# Byte-compiled / optimized / DLL files
__pycache__/
.venv
# editors
/.idea/
/.vscode/
/.zed
' >> .gitignoremain.py
python
import typer
app = typer.Typer()
@app.command()
def hello(name: str):
print(f"Hello {name}")
@app.command()
def goodbye(name: str, formal: bool = False):
if formal:
print(f"Goodbye Ms. {name}. Have a good day.")
else:
print(f"Bye {name}!")
if __name__ == "__main__":
app()Run It
Typer apps are CLIs, not servers — there's no dev server to start.
bash
python main.py hello Randy
python main.py goodbye Randy --formal
python main.py --helpCreate Repo
bash
gh repo create carbuyers_worker --privateCommit to repo
bash
git init
git add -A
git commit -m 'Initial Typer install'
git branch -M mainbash
git remote add origin git@github.com:zoonix/carbuyers_worker.gitbash
git push -u origin main