Skip to content

Commit

Permalink
(feat) added basic CLI, more features required
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Mar 30, 2024
1 parent 6267a5c commit b4580bd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
39 changes: 39 additions & 0 deletions avro/cli.py
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()
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@
'Programming Language :: Python :: 3.12',
'Topic :: Software Development :: Libraries :: Python Modules',
],
extras_require={
'cli': ['click>=8.0.0'],
},
entry_points={
'console_scripts': [
'avro=avro.cli:main',
],
},
)

0 comments on commit b4580bd

Please sign in to comment.