Skip to content

Latest commit

 

History

History
118 lines (110 loc) · 7 KB

INDEX.md

File metadata and controls

118 lines (110 loc) · 7 KB

Index of the Example scripts

Introduction

There examples are from the excellent Typer documentation.

Some Rich stuff

Exiting the program

CLI Arguments

CLI Options

At this point in the tutorial there were examples about TAB completion using typer-cli. Although I followed the instructions, I couldn't get this to work on Windows or Mac so I'm leaving it out for now. Note if you install it and run typer --install-completion, it will alter your powershell or zsh startup.

This section also introduced the click Context which you get access to by declaring a function parameter of type typer.Context. I expect this will be revisited with later examples.

Commands

I noticed that --help for an explicit application shows --install-completion and --show-completion. I'm not currently using completion as I had issues so it might be nice if those options could be hidden.

Parameter Types

SubCommands

Example 1 with separate files:

The core idea is to add a typer.Typer() app inside another.
We start with a small app to manage items. Then we find we need to manage users. So we create a third app to tie them together:

note that we are composing here. items.py and users.py work as both individual apps and as command groups for app1.py