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

[((25, 22, 25, 43), 'fiepipedesktoplib.gitlabserver.shell.server_name_var_command.GitLabServerNameVar', 'GitLabServerNameVar', ({}, {}), '()', False, 'from fiepipedesktoplib.gitlabserver.shell.server_name_var_command import GitLabServerNameVar\n'), ((27, 15, 27, 45), 'fiepipedesktoplib.gitlabserver.shell.gitlabserver.GitLabServerShell', 'GitLabServerShell', ({(27, 33, 27, 44): 'server_name'}, {}), '(server_name)', False, 'from fiepipedesktoplib.gitlabserver.shell.gitlabserver import GitLabServerShell\n'), ((19, 80, 19, 119), 'fiepipedesktoplib.gitlabserver.shell.gitlab_hostname_input_ui.GitLabHostnameInputDefaultShellUI', 'GitLabHostnameInputDefaultShellUI', ({(19, 114, 19, 118): 'self'}, {}), '(self)', False, 'from fiepipedesktoplib.gitlabserver.shell.gitlab_hostname_input_ui import GitLabHostnameInputDefaultShellUI\n'), ((20, 80, 20, 119), 'fiepipedesktoplib.gitlabserver.shell.gitlab_username_input_ui.GitLabUsernameInputDefaultShellUI', 'GitLabUsernameInputDefaultShellUI', ({(20, 114, 20, 118): 'self'}, {}), '(self)', False, 'from fiepipedesktoplib.gitlabserver.shell.gitlab_username_input_ui import GitLabUsernameInputDefaultShellUI\n'), ((21, 85, 21, 128), 'fiepipedesktoplib.gitlabserver.shell.gitlab_private_token_input_ui.GitLabPrivateTokenInputDefaultShellUI', 'GitLabPrivateTokenInputDefaultShellUI', ({(21, 123, 21, 127): 'self'}, {}), '(self)', False, 'from fiepipedesktoplib.gitlabserver.shell.gitlab_private_token_input_ui import GitLabPrivateTokenInputDefaultShellUI\n')]