Skip to content

Commit

Permalink
Add Typer CLI App code
Browse files Browse the repository at this point in the history
  • Loading branch information
lpozo committed Aug 23, 2021
1 parent 4fd6277 commit c5cd1cd
Show file tree
Hide file tree
Showing 74 changed files with 2,661 additions and 0 deletions.
94 changes: 94 additions & 0 deletions typer-cli-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# RP to-do

**RP to-do** is a command-line interface application built with [Typer](https://typer.tiangolo.com/) to help you manage your to-do list.

## Installation

To run **RP to-do**, you need to run the following steps:

1. Download the application's source code to a `rptodo_project/` directory
2. Create a Python virtual environment and activate it

```sh
$ cd rptodo_project/
$ python -m venv ./venv
$ source venv/bin/activate
(venv) $
```

2. Install the dependencies

```sh
(venv) $ python -m pip install -r requirements.txt
```

3. Initialize the application

```sh
(venv) $ python -m rptodo init
```

This command asks you to introduce the file path to store the application's database. You can also accept the default file path by pressing enter.

## Usage

Once you've download the source code and run the installation steps, you can run the following command to access the application's usage description:

```sh
$ python -m rptodo --help
Usage: rptodo [OPTIONS] COMMAND [ARGS]...

Options:
-v, --version Show the application's version and exit.
--install-completion Install completion for the current shell.
--show-completion Show completion for the current shell, to copy it
or customize the installation.
--help Show this message and exit.
Commands:
add Add a new to-do with a DESCRIPTION.
init Initialize the to-do database.
list-all List all to-dos.
remove Remove a to-do using its TODO_ID.
remove-all Remove all to-dos.
set-done Set a to-do as done using its TODO_ID.
```
You can also access the help message for specific commands by typing the command and then `--help`. For example, to display the help content for the `add` command, you can run the following:
```sh
$ python -m rptodo add --help
Usage: rptodo add [OPTIONS] DESCRIPTION...
Add a new to-do with a DESCRIPTION.
Arguments:
DESCRIPTION... [required]
Options:
-p, --priority INTEGER RANGE [default: 2]
--help Show this message and exit.
```
Calling `--help` on each command provides specific and useful information about how to use the command at hand.
## Features
**RP to-do** has the following features:
- **`init`** initializes the application's to-do database.
- **`add DESCRIPTION`** adds a new to-do to the database with a `DESCRIPTION`.
- **`list-all`** lists all the to-dos in the database.
- **`set-done TODO_ID`** set a to-do as done using its `TODO_ID`.
- **`remove TODO_ID`** remove a to-do from the database using its `TODO_ID`.
- **`remove-all`** remove all the to-dos in the database.

## Release History

- 0.1.0
- A work in progress

## About the Author

Leodanis Pozo Ramos - Email: [email protected]
94 changes: 94 additions & 0 deletions typer-cli-python/source_code_final/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# RP to-do

**RP to-do** is a command-line interface application built with [Typer](https://typer.tiangolo.com/) to help you manage your to-do list.

## Installation

To run **RP to-do**, you need to run the following steps:

1. Download the application's source code to a `rptodo_project/` directory
2. Create a Python virtual environment and activate it

```sh
$ cd rptodo_project/
$ python -m venv ./venv
$ source venv/bin/activate
(venv) $
```

2. Install the dependencies

```sh
(venv) $ python -m pip install -r requirements.txt
```

3. Initialize the application

```sh
(venv) $ python -m rptodo init
```

This command asks you to introduce the file path to store the application's database. You can also accept the default file path by pressing enter.

## Usage

Once you've download the source code and run the installation steps, you can run the following command to access the application's usage description:

```sh
$ python -m rptodo --help
Usage: rptodo [OPTIONS] COMMAND [ARGS]...

Options:
-v, --version Show the application's version and exit.
--install-completion Install completion for the current shell.
--show-completion Show completion for the current shell, to copy it
or customize the installation.
--help Show this message and exit.
Commands:
add Add a new to-do with a DESCRIPTION.
init Initialize the to-do database.
list-all List all to-dos.
remove Remove a to-do using its TODO_ID.
remove-all Remove all to-dos.
set-done Set a to-do as done using its TODO_ID.
```
You can also access the help message for specific commands by typing the command and then `--help`. For example, to display the help content for the `add` command, you can run the following:
```sh
$ python -m rptodo add --help
Usage: rptodo add [OPTIONS] DESCRIPTION...
Add a new to-do with a DESCRIPTION.
Arguments:
DESCRIPTION... [required]
Options:
-p, --priority INTEGER RANGE [default: 2]
--help Show this message and exit.
```
Calling `--help` on each command provides specific and useful information about how to use the command at hand.
## Features
**RP to-do** has the following features:
- **`init`** initializes the application's to-do database.
- **`add DESCRIPTION`** adds a new to-do to the database with a `DESCRIPTION`.
- **`list-all`** lists all the to-dos in the database.
- **`set-done TODO_ID`** set a to-do as done using its `TODO_ID`.
- **`remove TODO_ID`** remove a to-do from the database using its `TODO_ID`.
- **`remove-all`** remove all the to-dos in the database.

## Release History

- 0.1.0
- A work in progress

## About the Author

Leodanis Pozo Ramos - Email: [email protected]
3 changes: 3 additions & 0 deletions typer-cli-python/source_code_final/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
typer[all]==0.3.2
poetry==1.1.7
pytest==6.2.4
22 changes: 22 additions & 0 deletions typer-cli-python/source_code_final/rptodo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Top-level package for RP to-do."""

__app_name__ = "rptodo"
__version__ = "0.1.0"

(
SUCCESS,
DIR_ERROR,
FILE_ERROR,
DB_READ_ERROR,
DB_WRITE_ERROR,
JSON_ERROR,
ID_ERROR,
) = range(7)

ERRORS = {
DIR_ERROR: "config directory error",
FILE_ERROR: "config file error",
DB_READ_ERROR: "database read error",
DB_WRITE_ERROR: "database write error",
ID_ERROR: "to-do id error",
}
11 changes: 11 additions & 0 deletions typer-cli-python/source_code_final/rptodo/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""RP to-do entry point script."""

from rptodo import cli, __app_name__


def main():
cli.app(prog_name=__app_name__)


if __name__ == "__main__":
main()
Loading

0 comments on commit c5cd1cd

Please sign in to comment.