use argparse for commands instead of Click
This commit is contained in:
parent
83c00fee5d
commit
4c97be7226
3 changed files with 19 additions and 16 deletions
|
@ -7,7 +7,7 @@ A python package to set reverse dns in ungleich vm.
|
||||||
installing the package via pip (python3 required)
|
installing the package via pip (python3 required)
|
||||||
|
|
||||||
```angular2
|
```angular2
|
||||||
python3 -m pip install ungleich-cli --user
|
python3 -m pip install ungleich-cli
|
||||||
```
|
```
|
||||||
after installed you can set the reverse dns by typing
|
after installed you can set the reverse dns by typing
|
||||||
|
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -24,7 +24,6 @@ setup(
|
||||||
|
|
||||||
py_modules=['ungleichcli'],
|
py_modules=['ungleichcli'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Click',
|
|
||||||
'requests',
|
'requests',
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
import requests
|
import requests
|
||||||
import click
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
def msg(name=None):
|
||||||
@click.argument('dns', required=False)
|
return '''ungleich-cli --set-reverse <ipv6adrress> --user <username> --token <token> --name <hostname>'''
|
||||||
@click.option('--set-reverse', help='REQUIRED: IPv6 Address of your VM', required=True)
|
|
||||||
@click.option('--user', help='Your ungleich username', required=True)
|
|
||||||
@click.option('--token', help='REQUIRED: Your ungleich 6 digit OTP generated token', type=int)
|
|
||||||
@click.option('--name', help='REQUIRED: Hostname', required=True)
|
|
||||||
def cli(dns, set_reverse, user, token, name):
|
|
||||||
"""This script set the reverse dns for your VM
|
|
||||||
|
|
||||||
Example Usage:
|
|
||||||
|
|
||||||
ungleich-cli dns --set-reverse <ip> --user <username> --token <token> --name mirror.example.com
|
parser = argparse.ArgumentParser(description="This script set the reverse dns for your VM", usage=msg())
|
||||||
|
|
||||||
"""
|
parser.add_argument('--set-reverse', help='REQUIRED: IPv6 Address of your VM', metavar='', required=True)
|
||||||
r = requests.post('https://ungleich.ch/dns/reverse/', json={'username': user, 'token': token, 'ipaddress': set_reverse, 'name': name})
|
parser.add_argument('--user', help='Your ungleich username', metavar='', required=True)
|
||||||
return click.echo(r.text)
|
parser.add_argument('--token', help='Your ungleich 6 digit OTP generated token', metavar='', type=int, required=True)
|
||||||
|
parser.add_argument('--name', help='Hostname', metavar='', required=True)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def cli():
|
||||||
|
"""A dummy endpoint, to check what endpoint will be reverse-dns service."""
|
||||||
|
r = requests.post(
|
||||||
|
'https://en53kfc0hydpg.x.pipedream.net',
|
||||||
|
json={'username': args.user, 'token': args.token, 'ipaddress': args.set_reverse, 'name': args.name})
|
||||||
|
return r.text
|
||||||
|
|
Loading…
Reference in a new issue