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

41 lines
1.2 KiB
Python

#!/usr/bin/env python
# encoding: utf-8
import click
import loaih.versions as versions
import re, sys, json
@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 = []
if '.' in query:
b.append(versions.Build(query))
else:
# In case of names, we might want to loop for versions. So we before
# get the versions available, based on query.
vers = versions.Base.namedver(query)
if len(vers) != 1:
for v in vers:
b.append(versions.Build(v))
else:
b = versions.Build(vers[0])
if output.lower() == 'json':
output = {
'query': query,
'version': b.version,
'basedirurl': b.basedirurl
}
print(json.dumps(output))
else:
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']))
if __name__ == '__main__':
getversion()