CLI apps with
type annotations and shell completion
Slide 2
Slide 2 text
Who am I?
Sebastián Ramírez
github.com/tiangolo
linkedin.com/in/tiangolo
twitter.com/tiangolo
tiangolo.com
Berlin, Germany
Senior Staff Software Engineer at
I created:
➕
External Consultant
for other teams
Slide 3
Slide 3 text
About Typer
● 8K+ GitHub stars
● FastAPI's little sibling
● Powered by Click
@tiangolo
Slide 4
Slide 4 text
Command Line Interfaces (CLI) or Terminals
@tiangolo
● Text based
● You send program and parameters
● Computer goes beep boop
● Maybe output
● Examples of CLI apps: git, ssh, pip
Slide 5
Slide 5 text
Simple function with type annotations
@tiangolo
Slide 6
Slide 6 text
Simple function with type annotations
@tiangolo
Slide 7
Slide 7 text
Why type annotations - error checks
@tiangolo
Slide 8
Slide 8 text
Why type annotations - completion
@tiangolo
Slide 9
Slide 9 text
Simple function with type annotations - recap
@tiangolo
Simple scripts - more help in the terminal
@tiangolo
Slide 19
Slide 19 text
Simple scripts - help for parameters
@tiangolo
Slide 20
Slide 20 text
Simple scripts - help for parameters in the terminal
@tiangolo
Slide 21
Slide 21 text
A Typer app
@tiangolo
Slide 22
Slide 22 text
A Typer app - app object
@tiangolo
Slide 23
Slide 23 text
A Typer app - decorator
@tiangolo
Slide 24
Slide 24 text
A Typer app - call the app
@tiangolo
Slide 25
Slide 25 text
A Typer app - supergreet
@tiangolo
Slide 26
Slide 26 text
Install completion
@tiangolo
✨ Works for everything:
● Zsh
● Bash
● Fish
● PowerShell
Slide 27
Slide 27 text
Use completion
@tiangolo
Slide 28
Slide 28 text
Use completion
@tiangolo
Slide 29
Slide 29 text
Use completion
@tiangolo
Slide 30
Slide 30 text
Use completion
@tiangolo
Slide 31
Slide 31 text
Use completion
@tiangolo
Slide 32
Slide 32 text
Completion
@tiangolo
🧙 Works by default and can be used for:
● Deeply nested commands
● CLI Options and CLI Arguments
● Custom data (e.g. remote, from an API)
● etc.
Slide 33
Slide 33 text
Commands
@tiangolo
Slide 34
Slide 34 text
Commands - hi
@tiangolo
Slide 35
Slide 35 text
Commands - bye
@tiangolo
Slide 36
Slide 36 text
Help with commands
@tiangolo
Slide 37
Slide 37 text
Commands - hi again
@tiangolo
Slide 38
Slide 38 text
Commands --help for hi
@tiangolo
Slide 39
Slide 39 text
Command hi in terminal
@tiangolo
Slide 40
Slide 40 text
Commands - bye
@tiangolo
Slide 41
Slide 41 text
Commands --help for bye
@tiangolo
Slide 42
Slide 42 text
More Typer features
@tiangolo
● 🥅 Boolean flags
● ❓ Prompts
● 🔒 Ask passwords
● 🚀 Launch apps (e.g. a browser)
● ✅ Easy testing
● ✨ More…