Skip to content

Commit

Permalink
Merge pull request #2 from Siddhesh-Agarwal/cli
Browse files Browse the repository at this point in the history
added CLI Tool
  • Loading branch information
Siddhesh-Agarwal committed May 13, 2024
2 parents 012d666 + b5b9f40 commit f9df5b9
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 6 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ _______________________

## 📥 Installation

pip install the library:
You can use the [pip](https://pypi.org/project/pip/) package manager to install the library.

```sh
pip install cryptmoji
```

Check the [Documentation](https://siddhesh-agarwal.github.io/cryptmoji/)
or use [poetry](https://python-poetry.org/):

```sh
poetry add cryptmoji
```

> Check the [Documentation](https://siddhesh-agarwal.github.io/cryptmoji/)
## 📝 Usage

Expand All @@ -34,3 +40,22 @@ print(decrypted)
# 'Hello, world!'
```

## Command line tool

### Installation

```sh
pip install cryptmoji[cli]
```

### Usage

```sh
$ cryptmoji encrypt "Hello World"
Key (optional):
🎿🏑🏸🏹🐁🍻🏑🐁🐄🏤🏪

$ cryptmoji decrypt "🎿🏑🏸🏹🐁🍻🏑🐁🐄🏤🏪"
Key (optional):
Hello World
```
32 changes: 32 additions & 0 deletions cryptmoji/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from rich.console import Console
from typer import Typer

from cryptmoji.main import decrypt, encrypt

app = Typer()
console = Console()


@app.command("encrypt")
def cli_encrypt(text: str):
"""Encrypts a string as a string of emojis."""
key = console.input(
"Key (optional): ",
markup=False,
emoji=False,
password=True,
)

console.print(encrypt(text, key=key if key else None))


@app.command("decrypt")
def cli_decrypt(text: str):
"""Decrypts a string of emojis."""
key = console.input(
"Key (optional): ",
markup=False,
emoji=False,
password=True,
)
console.print(decrypt(text, key=key if key else None))
38 changes: 36 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ _______________________

## 📥 Installation

pip install the library:
You can use the [pip](https://pypi.org/project/pip/) package manager to install the library.

```bash
```sh
pip install cryptmoji
```

or use [poetry](https://python-poetry.org/):

```sh
poetry add cryptmoji
```

_______________________

## 📝 Usage
Expand Down Expand Up @@ -86,3 +92,31 @@ decrypted = decrypt(encrypted, key=key)
print(decrypted)
# Hello, world!
```

_______________________

## Command line tool

### Installation

```sh
pip install cryptmoji[cli]
```

### Usage

To encrypt:

```sh
$ cryptmoji encrypt "Hello World"
Key (optional):
🌾🍛🍢🍢🍥🌕🌉🍭🍥🍨🍢🍚🌊
```

To decrypt:

```sh
$ cryptmoji decrypt "🌾🍛🍢🍢🍥🌕🌉🍭🍥🍨🍢🍚🌊"
Key (optional):
Hello World
```
176 changes: 176 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -31,8 +30,15 @@ classifiers = [
"Typing :: Typed",
]

[tool.poetry.scripts]
cryptmoji = "cryptmoji.cli:app"

[tool.poetry.dependencies]
python = "^3.6"
python = ">=3.7.0,<4.0"

[tool.poetry.group.cli.dependencies]
typer = {extras = ["all"], version = "^0.12.3"}
rich = "^13.7.1"

[build-system]
requires = ["poetry-core>=2.0.0"]
Expand Down

0 comments on commit f9df5b9

Please sign in to comment.