1
0
This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
loappimage-helpers/scripts/loaih-getversion

35 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2022-03-17 02:30:16 +01:00
#!/usr/bin/env python
# encoding: utf-8
2022-03-20 23:57:45 +01:00
import click
from loaih.versions import BuildVersion
2022-03-19 00:50:07 +01:00
import re, sys, json
2022-03-17 02:30:16 +01:00
2022-03-20 23:57:45 +01: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-19 00:50:07 +01:00
else:
2022-03-20 23:57:45 +01: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 02:30:16 +01:00
2022-03-19 00:50:07 +01:00
if __name__ == '__main__':
2022-03-20 23:57:45 +01:00
getversion()