Skip to content

Commit

Permalink
print as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
janvanmansum committed Nov 28, 2023
1 parent 9a83029 commit 646f871
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/datastation/datastation_component_versions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import argparse

from rich.console import Console
from rich.table import Table

Expand All @@ -8,19 +10,30 @@

def main():
config = init()

parser = argparse.ArgumentParser(
description='Gets the version of all Data Station components in this installation.')
parser.add_argument('--json', dest='json', action='store_true', help='Output as JSON')
args = parser.parse_args()

components = get_rpm_versions(config['version_info']['dans_rpm_module_prefix'])
dataverse_version = get_dataverse_version(config['version_info']['dataverse_application_path'])
dataverse_build_number = get_dataverse_build_number(config['version_info']['dataverse_application_path'])
components['dataverse'] = f'{dataverse_version} build {dataverse_build_number}'
payara_version = get_payara_version(config['version_info']['payara_install_path'])
components['payara'] = payara_version
table = Table(title="Data Station Component Versions")
table.add_column("Component")
table.add_column("Version")
for component in components:
table.add_row(component, components[component])
console = Console()
console.print(table)

if args.json:
print(components)
return
else:
table = Table(title="Data Station Component Versions")
table.add_column("Component")
table.add_column("Version")
for component in components:
table.add_row(component, components[component])
console = Console()
console.print(table)


if __name__ == '__main__':
Expand Down

0 comments on commit 646f871

Please sign in to comment.