-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) added basic CLI, more features required
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-License-Identifier: MIT | ||
|
||
|
||
# Imports. | ||
import avro | ||
|
||
|
||
# The main function for the cli. | ||
def main(): | ||
# Import click but only if it's available. | ||
try: | ||
import click | ||
except ImportError: | ||
return print('In order to enable CLI, please install avro.py using: pip install avro.py[cli]') | ||
|
||
# Define the command group. | ||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
# Define the command. | ||
@cli.command('parse', help='Parse a given text to Bangla.') | ||
@click.argument('text') | ||
def _parse(text: str): | ||
click.echo(avro.parse(text)) | ||
|
||
# Define another command. | ||
@cli.command('reverse', help='Reverse a given text to English.') | ||
@click.argument('text') | ||
def _reverse(text: str): | ||
click.echo(avro.reverse(text)) | ||
|
||
# Run the command. | ||
cli() | ||
|
||
|
||
# Run the main function. | ||
if __name__ == '__main__': | ||
main() |
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