Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI commands to the package #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

andredelft
Copy link

@andredelft andredelft commented Oct 1, 2022

Hi!

Thanks for this great package! I use it a lot, and thought it might be helpfull to use it directly from the terminal, to improve my workflow. I therefore created the two terminal commands beta-to-uni and uni-to-beta using click. I have created this PR to share this with you, should you be interested in it as well! Please refer to the added section in the README for instructions.

Best,

André

betacode/cli.py Outdated


@click.command()
@click.argument("text", nargs=-1, type=str)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think allowing a file to be input would be a useful addition (so either text or file input). It'd also make it easier to convert larger entries on the fly.

I know I'd also be paranoid about if shell does any magic to the escape characters :)

output can just be to stdout which user redirects as necessary.

Copy link
Author

@andredelft andredelft Nov 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now added this suggestion. All sorts of cool chaining is now possible, e.g.:

$ beta-to-uni < some_input_file.txt > some_output_file.txt
$ echo λόγος | uni-to-beta
$ cat some_input_file.txt | beta-to-uni

@matgrioni
Copy link
Owner

Thanks André for the PR! Glad to know this has been helpful to you.

To me it looks like a good direction. I think it should be taken. I am thinking of moving this project to poetry to make it easier to support packaging and releases. In which case poetry supports cli commands and doesn't seem interoperable with click so I'd likely have to move move to that. But for now, this is a good addition and hope it simplifies things for you.

@andredelft
Copy link
Author

andredelft commented Oct 10, 2022

Thanks for the feedback, I will soon take the time to process it.

As for your comment regarding poetry: I'm not very experienced with it, but poetry supports a scripts section in pyproject.toml. Perhaps this can be used as an equivalent to the entry_points from setup.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants