-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert to Typer * Fix quality feedback * Ignore broken Typer Context reference in docs * Bump version
- Loading branch information
Showing
27 changed files
with
255 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
docs/architecture/decisions/0007-use-typer-for-cli-parsing.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 7. Use Typer for CLI parsing | ||
|
||
Date: 2024-05-10 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
Supersedes [5. Use Click for CLI parsing](0005-use-click-for-cli-parsing.md) | ||
|
||
## Context | ||
|
||
Type safety is important to maintainability and correctness of code, especially in systems that accept arbitrary user input. | ||
Command-line arguments and options in most CLI frameworks can be annotated with type hints, but many frameworks require specifying information about the CLI arguments and the handler function arguments in a redundant way. | ||
Typer is a library that uses Python type hints to generate a CLI parser, reducing the amount of boilerplate code needed to create a CLI. | ||
|
||
## Decision | ||
|
||
Use Typer for CLI parsing in the project. | ||
|
||
## Consequences | ||
|
||
- Developers can use type hints to specify the types of CLI arguments and options. | ||
- repo-man can be composed into other Typer-based applications. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import click | ||
import typer | ||
|
||
from repo_man.consts import REPO_TYPES_CFG | ||
from repo_man.utils import ensure_config_file_exists | ||
|
||
|
||
@click.command | ||
def edit() -> None: | ||
"""Edit the repo-man configuration manually""" | ||
|
||
ensure_config_file_exists() | ||
|
||
click.edit(filename=REPO_TYPES_CFG) | ||
typer.edit(filename=REPO_TYPES_CFG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
from pathlib import Path | ||
from typing import Annotated | ||
|
||
import click | ||
import typer | ||
|
||
from repo_man.consts import REPO_TYPES_CFG | ||
|
||
|
||
@click.command | ||
@click.argument("path", type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path)) | ||
def implode(path: Path) -> None: | ||
def implode(path: Annotated[Path, typer.Argument(exists=True, file_okay=False, dir_okay=True)]) -> None: | ||
"""Remove repo-man configuration for the specified directory""" | ||
|
||
click.confirm(click.style("Are you sure you want to do this?", fg="yellow"), abort=True) | ||
typer.confirm(typer.style("Are you sure you want to do this?", fg="yellow"), abort=True) | ||
(path / REPO_TYPES_CFG).unlink(missing_ok=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.