add prompt

This commit is contained in:
alicezou 2022-03-27 10:33:54 -04:00
parent 9917f2ac3a
commit b07b0e2f7e
2 changed files with 9 additions and 1 deletions

View file

@ -903,7 +903,9 @@ class Database:
def _path_checker(self, path):
newpath = os.path.dirname(path)
if not os.path.isdir(newpath):
os.makedirs(newpath)
from beets.ui.commands import database_dir_creation
if database_dir_creation(newpath):
os.makedirs(newpath)
def __init__(self, path, timeout=5.0):

View file

@ -1398,6 +1398,12 @@ version_cmd = ui.Subcommand(
version_cmd.func = show_version
default_commands.append(version_cmd)
# database_location: return true if user wants to create the parent directories.
def database_dir_creation(path):
# Ask the user for a choice.
return ui.input_yn("{} does not exist, create it (Y/n)?"
.format(displayable_path(path)))
# modify: Declaratively change metadata.