Add option to open config in vim

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
nathom 2021-06-08 23:18:30 -07:00
parent bbc6e3ec8a
commit 14710d536a

View file

@ -275,6 +275,12 @@ def lastfm(ctx, source, url):
help="Reset the config file, keeping the credentials",
)
@click.option("-p", "--path", is_flag=True, help="Show the config file's path")
@click.option(
"-ov",
"--open-vim",
is_flag=True,
help="Open the config file in the vim text editor.",
)
@click.pass_context
def config(ctx, **kwargs):
"""Manage the streamrip configuration file."""
@ -291,6 +297,9 @@ def config(ctx, **kwargs):
click.secho(f"Opening {CONFIG_PATH}", fg="green")
click.launch(CONFIG_PATH)
if kwargs["open_vim"]:
os.system(f"vim '{CONFIG_PATH}'")
if kwargs["directory"]:
config_dir = os.path.dirname(CONFIG_PATH)
click.secho(f"Opening {config_dir}", fg="green")