Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beets/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ def parse_csl_callback(
):
from beets.ui.commands.config import config_edit

return config_edit()
return config_edit(options)

test_lib = bool(lib)
subcommands, lib = _setup(options, lib)
Expand Down
9 changes: 6 additions & 3 deletions beets/ui/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def config_func(lib, opts, args):

# Open in editor.
elif opts.edit:
config_edit()
# Note: This branch *should* be unreachable
# since the normal flow should be short-circuited
# by the special case in ui._raw_main
config_edit(opts)

# Dump configuration.
else:
Expand All @@ -41,11 +44,11 @@ def config_func(lib, opts, args):
print("Empty configuration")


def config_edit():
def config_edit(cli_options):
"""Open a program to edit the user configuration.
An empty config file is created if no existing config file exists.
"""
path = config.user_config_path()
path = cli_options.config or config.user_config_path()
editor = editor_command()
try:
if not os.path.isfile(path):
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Bug fixes:
audio-features endpoint, the plugin logs a warning once and skips audio
features for all remaining tracks in the session, avoiding unnecessary API
calls and rate limit exhaustion.
- Running `beet --config <mypath> config -e` now edits `<mypath>` rather than
the default config path. :bug:`5652`
- :doc:`plugins/lyrics`: Accepts strings for lyrics sources (previously only
accepted a list of strings). :bug:`5962`

Expand Down
8 changes: 8 additions & 0 deletions test/ui/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,11 @@ def test_edit_invalid_config_file(self):
with patch("os.execlp") as execlp:
self.run_command("config", "-e")
execlp.assert_called_once_with("myeditor", "myeditor", self.config_path)

def test_edit_config_with_custom_config_path(self):
os.environ["EDITOR"] = "myeditor"
with patch("os.execlp") as execlp:
self.run_command("--config", self.cli_config_path, "config", "-e")
execlp.assert_called_once_with(
"myeditor", "myeditor", self.cli_config_path
)
Loading