Skip to content

Commit

Permalink
started work on default keys
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoEg committed Jun 8, 2024
1 parent 5d2a6c2 commit baa47f2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions installation_instruction/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sys import exit
from os.path import isfile
from subprocess import run
import platform

import click

Expand Down Expand Up @@ -42,6 +43,23 @@ def __init__(self, *args, **kwargs):
options_metavar="",
)

def _get_system(self, option_types):
system = platform.system().lower()
system_names = {
'linux': 'lin',
'linux2': 'lin',
'darwin': 'mac',
'win32': 'win',
}
if system in system_names.keys:
system = system_names.get(system)
for type in option_types:
if system in type.lower():
return type

return None


def get_command(self, ctx, config_file: str) -> click.Command|None:
if not isfile(config_file):
click.echo("Config file not found.")
Expand All @@ -54,6 +72,11 @@ def get_command(self, ctx, config_file: str) -> click.Command|None:
click.echo(click.style("Error (parsing options from schema): " + str(e), fg="red"))
exit(1)

for option in options:
if '__os__' in option.name:
system_default = self._get_system(option.type.choices)
if system_default:
option.default = system_default

def callback(**kwargs):
inst = instruction.validate_and_render(kwargs)
Expand Down

0 comments on commit baa47f2

Please sign in to comment.