gitmopy.prompt ============== .. py:module:: gitmopy.prompt .. autoapi-nested-parse:: Module handling user prompts. Prompts typically parameterize the commit message or ``gitmopy``'s behavior. Module Contents --------------- .. py:class:: GMPCompleter(key, max_results = 10) A completer that completes a text prompt from the user's history. Completions are sorted by most recent first. Returns up to ``self.max_results`` results. :param key: Key to complete from. Must be one of "scope", "title", "message". :type key: str :param max_results: Maximum number of results to return. Defaults to 10. :type max_results: int .. py:method:: get_completions(document, complete_event) Get completions for the current prompt. A completion is a string from the user's history that starts with all the characters in the current prompt. Case insensitive. :param document: The current document from the prompt. :type document: prompt_toolkit.document.Document :param complete_event: Unused. :type complete_event: Any :Yields: *Completion* -- A completion object that replaces the current user's input. .. py:attribute:: candidates .. py:attribute:: key .. py:attribute:: max_results :value: 10 .. py:function:: choose_remote_prompt(remotes) Prompt the user to select remotes to push to. :param remotes: Available remotes. :type remotes: List[str] :returns: Selected remotes. :rtype: List[str] .. py:function:: commit_prompt(config, state = None, simple = False) Prompt the user for emoji, scope title and message to make a commit message. Scope and message are optional. Scope and message can be bypassed from the config (run ``gitmopy config``) Scope, title and message are completed from the user's history if ``config["enable_history"]`` is ``True``. :param config: Configuration dictionary, from ``gitmopy config``. :type config: dict :param state: State dictionary from previous prompts. :type state: dict :returns: User-specified commit as a dict with keys ``"emoji"``, ``"scope"``, ``"title"``, ``"message"``. :rtype: dict .. py:function:: config_prompt() Prompt the user for configuration options. Will setup: - Whether to skip scope - Whether to skip message - Whether to capitalize title - Whether to enable history Will save the configuration in ``${APP_PATH}/config.yaml``. .. py:function:: confirm_prompt(message, default = False) Prompt the user to confirm an action. :param message: Message to display to the user. :type message: str :param default: Default value. :type default: bool :returns: User's confirmation. :rtype: bool .. py:function:: git_add_prompt(status) Start a prompt to select files to add to the commit. Files are grouped by status (unstaged, untracked). Files are all selected by default. :param status: Dictionary of files grouped by status. :type status: dict :returns: List of all the files selected by the user. :rtype: list .. py:function:: set_upstream_prompt(branch_name, remote_name) Prompt the user to set the upstream branch for a remote. :param branch_name: Branch name to set on the remote. :type branch_name: str :param remote_name: Remote name. :type remote_name: str :returns: Whether or not to set the upstream branch. :rtype: bool .. py:function:: try_func_with_keyboard_interrupt(func, *args, **kwargs) Try a function and catch a KeyboardInterrupt. .. py:function:: what_now_prompt(choices) Prompt the user to select what to do next. Choices must be a dictlike `{value: name}`. :param choices: Available choices. :type choices: Dict[str, str] :returns: User's choice. :rtype: str