loaih/scripts/loaih-getversion

35 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2022-03-17 01:30:16 +00:00
#!/usr/bin/env python
# encoding: utf-8
2022-03-20 22:57:45 +00:00
import click
from loaih.versions import BuildVersion
2022-03-18 23:50:07 +00:00
import re, sys, json
2022-03-17 01:30:16 +00:00
2022-03-20 22:57:45 +00:00
@click.command()
@click.option('-o', '--output', default = 'rundeck', type=click.Choice(['rundeck', 'json', 'text' ], case_sensitive=False), help="Output format, defaulting to Rundeck Key/Value data format. Options: rundeck,json,text")
@click.argument('query')
def getversion(query, output):
b = BuildVersion(query)
if output.lower() == 'rundeck':
print("""RUNDECK:DATA: query = {query}
RUNDECK:DATA: version = {version}
RUNDECK:DATA: x86 = {x86_url}
RUNDECK:DATA: x86_64 = {x86_64_url}""".format(query = query, version = b.version, x86_url = b.basedirurl['x86'], x86_64_url = b.basedirurl['x86_64']))
elif output.lower() == 'json':
output = {
'query': query,
'version': b.version,
'basedirurl': b.basedirurl
}
print(json.dumps(output))
2022-03-18 23:50:07 +00:00
else:
2022-03-20 22:57:45 +00:00
print("""query: {query}
version: {version}
x86: {x86_url}
x86_64: {x86_64_url}""".format(query = query, version = b.version, x86_url = b.basedirurl['x86'], x86_64_url = b.basedirurl['x86_64']))
2022-03-17 01:30:16 +00:00
2022-03-18 23:50:07 +00:00
if __name__ == '__main__':
2022-03-20 22:57:45 +00:00
getversion()