Skip to content

Commit

Permalink
Merge pull request #9 from MirrorShih/master
Browse files Browse the repository at this point in the history
feat: add command line
  • Loading branch information
louis70109 authored May 12, 2021
2 parents 3ee2559 + 57d54f6 commit 38f609c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README-zh_TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ print(revoke)
# {'status': 200, 'message': 'ok'}
```

## 在命令列中使用
```commandline
lotify --help
-t, --access_token TEXT access token [required]
-m, --message TEXT message to send [required]
-u, --image-url TEXT image url to send
-f, --image-file TEXT image file path to send
```

# 貢獻指南

請先 Fork 再 Clone:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ print(revoke)
# {'status': 200, 'message': 'ok'}
```

## Command Line Interface
```commandline
lotify --help
-t, --access_token TEXT access token [required]
-m, --message TEXT message to send [required]
-u, --image-url TEXT image url to send
-f, --image-file TEXT image file path to send
```

# Contributing

Fork before Clone the repository:
Expand Down
23 changes: 23 additions & 0 deletions lotifyCli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import click
from lotify.client import Client


@click.group()
def cli():
pass


@cli.command()
@click.option('-t', '--access_token', type=str, help='access token', required=True)
@click.option('-m', '--message', type=str, help='message to send', required=True)
@click.option('-u', '--image-url', type=str, help='image url to send', default="")
@click.option('-f', '--image-file', type=str, help='image file path to send', default="")
def send_message(message, access_token, image_url, image_file):
client = Client()
if image_url != "":
client.send_message_with_image_url(access_token, message, image_url, image_url)
elif image_file != "":
client.send_message_with_image_file(access_token, message, open(image_file, 'rb'))
else:
client.send_message(access_token, message)
click.echo("send successfully")
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests>=2.0
urllib3
urllib3
click>=7.1.2
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ def run_tests(self):
"Programming Language :: Python :: 3.8",
"Topic :: Software Development"
],
entry_points='''
[console_scripts]
lotify=lotifyCli:send_message
'''
)

0 comments on commit 38f609c

Please sign in to comment.