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
Plaintext
Raw 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
import loaih.versions as versions
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 = []
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])
2022-03-20 23:57:45 +01:00
if output.lower() == 'json':
2022-03-20 23:57:45 +01:00
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()