CLI#
moe.cli
Entry point for the CLI.
This module deals with parsing the arguments of moe
and related functionality.
For general shared CLI functionality, see the moe.util.cli
package.
Util#
moe.util.cli
This package contains shared functionality for the CLI.
- class PromptChoice(title: str, shortcut_key: str, func: Callable)#
Bases:
object
A single, user-selectable choice for a CLI prompt.
- title#
Title of the prompt choice that is displayed to the user.
- Type:
str
- shortcut_key#
Single character the user will use to select the choice.
Important
Ensure each shortcut key is not in use by another PromptChoice.
- Type:
str
- func#
The function that should get called if a choice is selected. The definition for how to call
func
should be specified by the plugin.- Type:
Callable
See also
- choice_prompt(prompt_choices: list[PromptChoice], question: str = 'What do you want to do?') PromptChoice #
Generates a user choice prompt.
- Parameters:
prompt_choices – Prompt choices to be used.
question – Question prompted to the user.
- Returns:
The chosen prompt choice.
- Raises:
SystemExit – Invalid user input.
- cli_query(session: Session, query_str: str, query_type: str) list[Album] | list[Extra] | list[Track] #
Wrapper around the core query call, with some added cli error handling.
- Parameters:
session – Library db session.
query_str – Query string to parse. See the query docs for more info.
query_type – Type of library item to return: either ‘album’, ‘extra’, or ‘track’.
- Returns:
All items matching the given query found in
args
.- Raises:
SystemExit – QueryError or no items returned from the query.
See also
- query_parser#
Argument parser for a query.
Passing this parser as a parent to your command allows your command to accept queries.
Example
ls_parser = cmd_parsers.add_parser( "list", description="Lists music in the library.", help="list music in the library", parents=[query_parser], )
Given parsed commandline arguments as
args
, you can then access the given query string asargs.query
and the query type asargs.query_type
. Both options can be passed directly tomoe.query.query()
ormoe.util.cli.cli_query()
.See also