gitmopy.prompt

Module handling user prompts.

Prompts typically parameterize the commit message or gitmopy’s behavior.

Module Contents

class gitmopy.prompt.GMPCompleter(key, max_results=10)[source]

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.

Parameters:
  • key (str) – Key to complete from. Must be one of “scope”, “title”, “message”.

  • max_results (int) – Maximum number of results to return. Defaults to 10.

get_completions(document, complete_event)[source]

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.

Parameters:
  • document (prompt_toolkit.document.Document) – The current document from the prompt.

  • complete_event (Any) – Unused.

Yields:

Completion – A completion object that replaces the current user’s input.

Return type:

prompt_toolkit.completion.Completion

candidates[source]
key[source]
max_results = 10[source]
gitmopy.prompt.choose_remote_prompt(remotes)[source]

Prompt the user to select remotes to push to.

Parameters:

remotes (List[str]) – Available remotes.

Returns:

Selected remotes.

Return type:

List[str]

gitmopy.prompt.commit_prompt(config, state=None, simple=False)[source]

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.

Parameters:
  • config (dict) – Configuration dictionary, from gitmopy config.

  • state (dict) – State dictionary from previous prompts.

  • simple (bool)

Returns:

User-specified commit as a dict with keys

"emoji", "scope", "title", "message".

Return type:

dict

gitmopy.prompt.config_prompt()[source]

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.

Return type:

None

gitmopy.prompt.confirm_prompt(message, default=False)[source]

Prompt the user to confirm an action.

Parameters:
  • message (str) – Message to display to the user.

  • default (bool) – Default value.

Returns:

User’s confirmation.

Return type:

bool

gitmopy.prompt.git_add_prompt(status)[source]

Start a prompt to select files to add to the commit.

Files are grouped by status (unstaged, untracked).

Files are all selected by default.

Parameters:

status (dict) – Dictionary of files grouped by status.

Returns:

List of all the files selected by the user.

Return type:

list

gitmopy.prompt.set_upstream_prompt(branch_name, remote_name)[source]

Prompt the user to set the upstream branch for a remote.

Parameters:
  • branch_name (str) – Branch name to set on the remote.

  • remote_name (str) – Remote name.

Returns:

Whether or not to set the upstream branch.

Return type:

bool

gitmopy.prompt.try_func_with_keyboard_interrupt(func, *args, **kwargs)[source]

Try a function and catch a KeyboardInterrupt.

Parameters:

func (Callable)

gitmopy.prompt.what_now_prompt(choices)[source]

Prompt the user to select what to do next.

Choices must be a dictlike {value: name}.

Parameters:

choices (Dict[str, str]) – Available choices.

Returns:

User’s choice.

Return type:

str