Added Argparse
This commit is contained in:
12
list.py
Normal file → Executable file
12
list.py
Normal file → Executable file
@@ -1,6 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
from hcloud import Client
|
||||
import argparse
|
||||
|
||||
# Get Servername
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("apiKey")
|
||||
args = parser.parse_args()
|
||||
apiKey = args.apiKey
|
||||
|
||||
# Please paste your API token here between the quotes
|
||||
client = Client(token=apiKey)
|
||||
|
||||
client = Client(token="JalvbaPbizgErC2PoBSmDiFX0TKW0WLzbarxwFyNtJpx1xCvnEx3LI1B2Thl836f") # Please paste your API token here between the quotes
|
||||
servers = client.servers.get_all()
|
||||
for server in servers:
|
||||
print("Servername:", server.name)
|
||||
|
||||
Reference in New Issue
Block a user