package eu.jonahbauer.wizard.client.cli.commands;

import eu.jonahbauer.wizard.client.cli.Client;
import eu.jonahbauer.wizard.client.cli.ClientSocket;
import eu.jonahbauer.wizard.client.cli.state.AwaitingConnection;
import eu.jonahbauer.wizard.client.cli.state.Lobby;
import eu.jonahbauer.wizard.common.messages.server.SessionListMessage;

import java.net.URI;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static picocli.CommandLine.*;

@Command(name = "\b", subcommands = {HelpCommand.class, QuitCommand.class})
public class MenuCommand {
    private final Client client;

    public MenuCommand(Client client) {
        this.client = client;
    }

    @Command(name = "connect", description = "Connects to the specified server")
    public AwaitingConnection connect(
            @Parameters(index = "0", paramLabel = "<uri>", description = "server uri") URI uri
    ) {
        ClientSocket socket = new ClientSocket(uri);
        client.setSocket(socket);
        socket.connect();
        return new AwaitingConnection();
    }
}
