red_pythontyper
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.4%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: RED0731
- License: mit
- Language: Python
- Default Branch: citation
- Size: 866 KB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Typer, build great CLIs. Easy to code. Based on Python type hints.
Documentation: https://typer.tiangolo.com
Source Code: https://github.com/tiangolo/typer
Typer is a library for building CLI applications that users will love using and developers will love creating. Based on Python 3.6+ type hints.
The key features are:
- Intuitive to write: Great editor support. Completion everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.
- Easy to use: It's easy to use for the final users. Automatic help, and automatic completion for all shells.
- Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
- Start simple: The simplest example adds only 2 lines of code to your app: 1 import, 1 function call.
- Grow large: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups of subcommands, with options and arguments.
FastAPI of CLIs
Typer is FastAPI's little sibling.
And it's intended to be the FastAPI of CLIs.
Requirements
Python 3.6+
Typer stands on the shoulders of a giant. Its only internal dependency is Click.
Installation
Note: that will include Rich. Rich is the recommended library to display information on the terminal, it is optional, but when installed, it's deeply integrated into Typer to display beautiful output.
Example
The absolute minimum
- Create a file
main.pywith:
```Python import typer
def main(name: str): print(f"Hello {name}")
if name == "main": typer.run(main) ```
Run it
Run your application:
Note: auto-completion works when you create a Python package and run it with --install-completion or when you use Typer CLI.
Example upgrade
This was the simplest example possible.
Now let's see one a bit more complex.
An example with two subcommands
Modify the file main.py.
Create a typer.Typer() app, and create two subcommands with their parameters.
```Python hl_lines="3 6 11 20" 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() ```
And that will:
- Explicitly create a
typer.Typerapp.- The previous
typer.runactually creates one implicitly for you.
- The previous
- Add two subcommands with
@app.command(). - Execute the
app()itself, as if it was a function (instead oftyper.run).
Run the upgraded example
Check the new help:
Now check the help for the hello command:
And now check the help for the goodbye command:
Now you can try out the new command line application:
Recap
In summary, you declare once the types of parameters (CLI arguments and CLI options) as function parameters.
You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard Python 3.6+.
For example, for an int:
Python
total: int
or for a bool flag:
Python
force: bool
And similarly for files, paths, enums (choices), etc. And there are tools to create groups of subcommands, add metadata, extra validation, etc.
You get: great editor support, including completion and type checks everywhere.
Your users get: automatic --help, auto-completion in their terminal (Bash, Zsh, Fish, PowerShell) when they install your package or when using Typer CLI.
For a more complete example including more features, see the Tutorial - User Guide.
Optional Dependencies
Typer uses Click internally. That's the only dependency.
But you can also install extras:
rich: and Typer will show nicely formatted errors automatically.shellingham: and Typer will automatically detect the current shell when installing completion.- With
shellinghamyou can just use--install-completion. - Without
shellingham, you have to pass the name of the shell to install completion for, e.g.--install-completion bash.
- With
You can install typer with rich and shellingham with pip install typer[all].
License
This project is licensed under the terms of the MIT license.
Owner
- Name: Alex Lynn
- Login: RED0731
- Kind: user
- Location: in sky
- Company: myown
- Repositories: 14
- Profile: https://github.com/RED0731
IT Developer
Citation (CITATION.cff)
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: Typer
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Sebastián
family-names: Ramírez
email: tiangolo@gmail.com
identifiers:
repository-code: 'https://github.com/tiangolo/typer'
url: 'https://typer.tiangolo.com'
abstract: >-
Typer, build great CLIs. Easy to code. Based on Python type hints.
keywords:
- typer
- click
license: MIT
GitHub Events
Total
Last Year
Dependencies
- Dockerfile * docker
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- dorny/paths-filter v2 composite
- re-actors/alls-green release/v1 composite
- ./.github/actions/comment-docs-preview-in-pr * composite
- actions/checkout v3 composite
- cloudflare/pages-action v1 composite
- dawidd6/action-download-artifact v2.27.0 composite
- tiangolo/issue-manager 0.4.0 composite
- actions/checkout v3 composite
- docker://tiangolo/latest-changes 0.0.3 composite
- mxschmitt/action-tmate v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/setup-python v4 composite
- dawidd6/action-download-artifact v2.26.0 composite
- actions/checkout v3 composite
- actions/download-artifact v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- python 3.7 build
