Esempio n. 1
0
def instance_menu():
    instances = load_existing_config()
    if not instances:
        print("No instances found!")
        return None
    counter = 0
    print("Bot instance menu\n")

    name_num_map = {}
    for name in list(instances.keys()):
        print("{}. {}\n".format(counter + 1, name))
        name_num_map[str(counter + 1)] = name
        counter += 1

    while True:
        selection = user_choice()
        try:
            selection = int(selection)
        except ValueError:
            print(
                "Invalid input! Please enter a number corresponding to an instance."
            )
        else:
            if selection not in list(range(1, counter + 1)):
                print("Invalid selection! Please try again")
            else:
                return name_num_map[str(selection)]
Esempio n. 2
0
async def reset_red():
    instances = load_existing_config()

    if not instances:
        print("No instance to delete.\n")
        return
    print(
        "WARNING: You are about to remove ALL Bot instances on this computer.")
    print("If you want to reset data of only one instance, "
          "please select option 5 in the launcher.")
    await asyncio.sleep(2)
    print("\nIf you continue you will remove these instanes.\n")
    for instance in list(instances.keys()):
        print("    - {}".format(instance))
    await asyncio.sleep(3)
    print('\nIf you want to reset all instances, type "I agree".')
    response = input("> ").strip()
    if response != "I agree":
        print("Cancelling...")
        return

    if confirm("\nDo you want to create a backup for an instance? (y/n) "):
        for index, instance in instances.items():
            print("\nRemoving {}...".format(index))
            await create_backup(index, instance)
            await remove_instance(index, instance)
    else:
        for index, instance in instances.items():
            await remove_instance(index, instance)
    print("All instances have been removed.")
Esempio n. 3
0
def parse_cli_args():
    parser = argparse.ArgumentParser(
        description="Red - Discord Bot's launcher (V3)", allow_abbrev=False
    )
    instances = load_existing_config()
    parser.add_argument(
        "instancename",
        metavar="instancename",
        type=str,
        nargs="?",
        help="The instance to run",
        choices=list(instances.keys()),
    )
    parser.add_argument("--start", "-s", help="Starts Red", action="store_true")
    parser.add_argument(
        "--auto-restart", help="Autorestarts Red in case of issues", action="store_true"
    )
    parser.add_argument("--update", help="Updates Red", action="store_true")
    parser.add_argument(
        "--update-dev", help="Updates Red from the Github repo", action="store_true"
    )
    parser.add_argument(
        "--voice", help="Installs extra 'voice' when updating", action="store_true"
    )
    parser.add_argument("--docs", help="Installs extra 'docs' when updating", action="store_true")
    parser.add_argument("--test", help="Installs extra 'test' when updating", action="store_true")
    parser.add_argument(
        "--mongo", help="Installs extra 'mongo' when updating", action="store_true"
    )
    parser.add_argument(
        "--debuginfo",
        help="Prints basic debug info that would be useful for support",
        action="store_true",
    )
    return parser.parse_known_args()