import typing

from fiepipelib.gitlabserver.data.gitlab_server import GitLabServer
from fiepipelib.gitlabserver.routines.manager import GitLabServerManagerInteractiveRoutines
from fiepipedesktoplib.gitlabserver.shell.gitlab_hostname_input_ui import GitLabHostnameInputDefaultShellUI
from fiepipedesktoplib.gitlabserver.shell.gitlab_username_input_ui import GitLabUsernameInputDefaultShellUI
from fiepipedesktoplib.gitlabserver.shell.gitlab_private_token_input_ui import GitLabPrivateTokenInputDefaultShellUI
from fiepipedesktoplib.gitlabserver.shell.gitlabserver import GitLabServerShell
from fiepipedesktoplib.gitlabserver.shell.server_name_var_command import GitLabServerNameVar
from fiepipedesktoplib.locallymanagedtypes.shells.AbstractLocalManagedTypeCommand import LocalManagedTypeCommand
from fiepipedesktoplib.shells.AbstractShell import AbstractShell
from fiepipedesktoplib.shells.variables.fqdn_var_command import FQDNVarCommand


class GitLabServerManagerShell(LocalManagedTypeCommand[GitLabServer]):

    def get_routines(self) -> GitLabServerManagerInteractiveRoutines:
        return GitLabServerManagerInteractiveRoutines(feedback_ui=self.get_feedback_ui(),
                                                      hostname_input_default_ui=GitLabHostnameInputDefaultShellUI(self),
                                                      username_input_default_ui=GitLabUsernameInputDefaultShellUI(self),
                                                      private_token_input_default_ui=GitLabPrivateTokenInputDefaultShellUI(self))

    def get_shell(self, item: GitLabServer) -> AbstractShell:
        # no shell currently.  We call super instead.
        server_name = GitLabServerNameVar()
        server_name.set_value(item.get_name())
        return GitLabServerShell(server_name)

    def get_plugin_names_v1(self) -> typing.List[str]:
        ret = super(GitLabServerManagerShell, self).get_plugin_names_v1()
        ret.append("gitlabserver.manager")
        return ret

    def get_prompt_text(self) -> str:
        return self.prompt_separator.join(['GitLabServer', 'Manager'])


def main():
    shell = GitLabServerManagerShell()
    shell.cmdloop()


if __name__ == '__main__':
    main()

[((1683, 1704), 'fiepipedesktoplib.gitlabserver.shell.server_name_var_command.GitLabServerNameVar', 'GitLabServerNameVar', ([], {}), '()\n', (1702, 1704), False, 'from fiepipedesktoplib.gitlabserver.shell.server_name_var_command import GitLabServerNameVar\n'), ((1767, 1797), 'fiepipedesktoplib.gitlabserver.shell.gitlabserver.GitLabServerShell', 'GitLabServerShell', (['server_name'], {}), '(server_name)\n', (1784, 1797), False, 'from fiepipedesktoplib.gitlabserver.shell.gitlabserver import GitLabServerShell\n'), ((1252, 1291), 'fiepipedesktoplib.gitlabserver.shell.gitlab_hostname_input_ui.GitLabHostnameInputDefaultShellUI', 'GitLabHostnameInputDefaultShellUI', (['self'], {}), '(self)\n', (1285, 1291), False, 'from fiepipedesktoplib.gitlabserver.shell.gitlab_hostname_input_ui import GitLabHostnameInputDefaultShellUI\n'), ((1373, 1412), 'fiepipedesktoplib.gitlabserver.shell.gitlab_username_input_ui.GitLabUsernameInputDefaultShellUI', 'GitLabUsernameInputDefaultShellUI', (['self'], {}), '(self)\n', (1406, 1412), False, 'from fiepipedesktoplib.gitlabserver.shell.gitlab_username_input_ui import GitLabUsernameInputDefaultShellUI\n'), ((1499, 1542), 'fiepipedesktoplib.gitlabserver.shell.gitlab_private_token_input_ui.GitLabPrivateTokenInputDefaultShellUI', 'GitLabPrivateTokenInputDefaultShellUI', (['self'], {}), '(self)\n', (1536, 1542), False, 'from fiepipedesktoplib.gitlabserver.shell.gitlab_private_token_input_ui import GitLabPrivateTokenInputDefaultShellUI\n')]