- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearning_cli.py
More file actions
Latest commit
24 lines (19 loc) · 730 Bytes
/
Copy pathlearning_cli.py
File metadata and controls
24 lines (19 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importclick
importurllib3
fromjsonplaceholder.servicesimportget_service_by_name
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@click.command()
@click.option("--entity", prompt="Entity",
help="The type of entity you want to work with")
@click.option("--action", prompt="Action",
help="The action you want to execute")
defhello(entity, action):
"""Simple program that execute a request to an API."""
service=get_service_by_name(entity)
ifservice:
click.echo("Results:")
click.echo(service.run_action(action))
else:
raiseclick.exceptions.BadOptionUsage("entity", "The value is not valid")
if__name__=='__main__':
hello()