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

Cli conversion pasters #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions rigatonibot/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import click
from pathlib import Path
import requests

@click.command()
@click.argument('filename', type=click.Path(exists=True, readable=True), nargs=1)
def cli(filename):
"""Usage:
run `python rigatonibot/cli.py <file>`,
it will create and output via terminal your `paste.rs` link"""
path = Path(filename).as_posix()

with open(path, 'r') as file:
data = file.read()
web_address = requests.post('http://paste.rs', data=data)

print(web_address.text)

if __name__ == '__main__':
cli()


# Ta esse eh o unico arquivo que soh eu tenho por enquanto:
"""
Ideias:
1- fazer primeiro via cli,
python rigatoni.py <arquivo>.py --> nao precisa ser py, mas acho que comece assim
--> a nao ser que converter pra txt sempre funcione
a) devolve o link criado no paste
b) abre direto no navegador o negocio criado

2- depois dar um jeito de fazer isso virar uma ferramenta sh
rigatoni <arquivo>.py

3- depois (ou antes) ja fazer um bot de telegrao
(eh bom pq dai a galera nao tem que instalar essa pomba no pc)

4- oferecer outras ferramentas de paste
rigatoni <arquivo> {paste, gist}
(ei, nao precisa ser .py!)
"""
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
name='rigatonibot',
version='1.0.0',
packages=find_packages(),
install_requires=['python-telegram-bot', 'requests'],
install_requires=['python-telegram-bot', 'requests', 'click',
'pathlib'],
entry_points='''
[console_scripts]
rigatonibot=rigatonibot.__main__:main
Expand Down