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.
Import¶
moe.moe_import
Import prompt.
- candidate_prompt(new_album: Album, candidates: list[CandidateAlbum]) None¶
Runs the interactive prompt for a user to select a candidate to import.
- Parameters:
new_album – Album being added to the library.
candidates – List of candidates to choose from.
- Raises:
AbortImportError – Import prompt was aborted by the user.
- import_prompt(new_album: Album, candidate: CandidateAlbum) None¶
Runs the interactive prompt for the given album changes.
- Parameters:
new_album – Album being added to the library. Any changes will be applied to this album.
candidate – New candidate album with all metadata changes. Will be compared against
old_album.
- Raises:
AbortImportError – Import prompt was aborted by the user.
Util¶
moe.util.cli
This package contains shared functionality for the CLI.
- class PromptChoice(title: str, shortcut_key: str, func: Callable)¶
Bases:
objectA 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
funcshould be specified by the plugin.- Type:
collections.abc.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: QueryType) 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.
- 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.queryand the query type asargs.query_type. Both options can be passed directly tomoe.query.query()ormoe.util.cli.cli_query().See also