Exemplo n.º 1
0
def menu(arguments):
    if arguments['list']:
        if arguments['--YAML'] or arguments['--JSON']:
            where = dict(name=arguments['<name>']) if arguments['<name>'] else dict()
            systems = System.list(**where)
            common.dump(systems, toyaml=arguments['--YAML'], tojson=arguments['--JSON'], entry=lambda item: item.__dict__)

        else:
            _system_list_table(arguments)

    elif system_execute(arguments):
        pass

    else:
        try:
            if arguments['create']:
                System.create(**_system_create_kwargs(arguments))

            elif arguments['read']:
                system_read(arguments)

            elif arguments['set']:
                system_set(arguments)

            elif arguments['delete']:
                System(arguments['<name>']).delete()

            elif arguments['reset']:
                system_reset(arguments)

        except NameError as exc:
            print(PACKAGE_NAME, 'Error!', exc)
            sys.exit(1)