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 java.net.URI;

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();
    }
}
