|
1 |
| -import click |
2 |
| -import click_spinner |
3 |
| - |
4 |
| -from pindo_cli.http import Token, RefreshToken, Register, SMS, Balance, Organization |
5 |
| - |
6 |
| - |
7 |
| -@click.group() |
8 |
| -@click.option('--debug/--no-debug', default=False) |
9 |
| -@click.version_option(None, "--version", "-v") |
10 |
| -def cli(debug): |
11 |
| - """ |
12 |
| - Pindo CLI |
13 |
| - A simple Command Line Interface that allow you to create an account |
14 |
| - and request a token for using Pindo API |
15 |
| - """ |
16 |
| - |
17 |
| - |
18 |
| -@cli.command() # @cli, not @click! |
19 |
| -@click.option( |
20 |
| - '--username', '-u', prompt=True, help='Please enter your username') |
21 |
| -@click.option( |
22 |
| - '--password', '-p', |
23 |
| - prompt=True, hide_input=True, help='Please enter your password') |
24 |
| -def token(username, password): |
25 |
| - """ |
26 |
| - Request a token for using Pindo API. |
27 |
| - """ |
28 |
| - click.echo('token...') |
29 |
| - with click_spinner.spinner(): |
30 |
| - click.echo(Token(username, password)) |
31 |
| - |
32 |
| - |
33 |
| -@cli.command() # @cli, not @click! |
34 |
| -@click.option( |
35 |
| - '--username', '-u', prompt=True, help='Please enter your username') |
36 |
| -@click.option( |
37 |
| - '--password', '-p', |
38 |
| - prompt=True, hide_input=True, help='Please enter your password') |
39 |
| -def refresh_token(username, password): |
40 |
| - """ |
41 |
| - Refresh a Token. |
42 |
| - """ |
43 |
| - click.echo('token...') |
44 |
| - with click_spinner.spinner(): |
45 |
| - click.echo(RefreshToken(username, password)) |
46 |
| - |
47 |
| - |
48 |
| -@cli.command() |
49 |
| -@click.option( |
50 |
| - '--username', '-u', prompt=True, help='Please enter your username') |
51 |
| -@click.option( |
52 |
| - '--email', '-e', prompt=True, help='Please enter your email') |
53 |
| -@click.option( |
54 |
| - '--password', '-p', prompt=True, hide_input=True, confirmation_prompt=True, |
55 |
| - help='Please enter your password') |
56 |
| -def register(username, email, password): |
57 |
| - """ |
58 |
| - Create a new Pindo account. |
59 |
| - """ |
60 |
| - click.echo(Register(username, email, password)) |
61 |
| - |
62 |
| - |
63 |
| -@cli.command() |
64 |
| -@click.option('--token', prompt=True, help='API Token') |
65 |
| -@click.option( |
66 |
| - '--to', prompt=True, help='Receiver phone number (+250xxxxxx)', |
67 |
| - default='+250785383100') |
68 |
| -@click.option( |
69 |
| - '--text', prompt=True, help='Message to send', default='Hello Pindo') |
70 |
| -@click.option('--sender', prompt=True, default='Pindo', help='Sender name') |
71 |
| -def sms(token, to, text, sender): |
72 |
| - """ |
73 |
| - Send a test message |
74 |
| - """ |
75 |
| - click.echo(SMS(token, to, text, sender)) |
76 |
| - |
77 |
| - |
78 |
| -@cli.command() |
79 |
| -@click.option('--token', prompt=True, help='API Token') |
80 |
| -def balance(token): |
81 |
| - """ |
82 |
| - Get account balance |
83 |
| - """ |
84 |
| - click.echo(Balance(token)) |
85 |
| - |
86 |
| - |
87 |
| -@cli.command() |
88 |
| -@click.option('--token', prompt=True, help='API Token') |
89 |
| -@click.option('--name', prompt=True, help='Organization name') |
90 |
| -@click.option('--webhook_url', prompt=True, help='Webhook URL. Eg (https://pindo.io/dlr)') |
91 |
| -@click.option('--retries_count', prompt=True, type=(int), help='SMS retries count settings') |
92 |
| -def org(token, name, webhook_url, retries_count): |
93 |
| - """ |
94 |
| - Organization |
95 |
| - """ |
96 |
| - click.echo(Organization(token, name, webhook_url, retries_count)) |
| 1 | +__version__ = '0.1.0' |
0 commit comments