removing add from cli
This commit is contained in:
parent
8905aea30a
commit
e036eff4e2
|
@ -3,7 +3,7 @@ import os
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, List
|
from typing import Optional
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
from rich import print
|
from rich import print
|
||||||
|
@ -89,49 +89,6 @@ def get(
|
||||||
print(pl.as_dict)
|
print(pl.as_dict)
|
||||||
|
|
||||||
|
|
||||||
@playlist_app.command()
|
|
||||||
def add(
|
|
||||||
name: str = typer.Argument(
|
|
||||||
...,
|
|
||||||
help="The name of the playlist to create."
|
|
||||||
),
|
|
||||||
description: str = typer.Option(
|
|
||||||
None,
|
|
||||||
help="The description of the playlist."
|
|
||||||
),
|
|
||||||
tracks: List[str] = typer.Option(
|
|
||||||
None,
|
|
||||||
help="A list of tracks to add to the playlist."
|
|
||||||
),
|
|
||||||
exists_ok: bool = typer.Option(
|
|
||||||
True,
|
|
||||||
help="If True, it is okay if the playlist already exists."
|
|
||||||
),
|
|
||||||
multiples_ok: bool = typer.Option(
|
|
||||||
False,
|
|
||||||
help="If True, the same track can be added to the playlist multiple times."
|
|
||||||
)
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Create a new playlist with the specified name, unless it already exists.
|
|
||||||
"""
|
|
||||||
initialize()
|
|
||||||
with database_manager() as manager:
|
|
||||||
pl = Playlist(
|
|
||||||
slug=slugify(name),
|
|
||||||
session=manager.session,
|
|
||||||
name=name,
|
|
||||||
description=description,
|
|
||||||
create_if_not_exists=True)
|
|
||||||
if pl.exists:
|
|
||||||
if not exists_ok:
|
|
||||||
raise RuntimeError(f"Playlist with slug {pl.slug} already exists!")
|
|
||||||
logging.debug(pl.as_dict)
|
|
||||||
if tracks:
|
|
||||||
pl.add(tracks)
|
|
||||||
print(pl.as_dict)
|
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def scan(
|
def scan(
|
||||||
root: Optional[Path] = typer.Option(
|
root: Optional[Path] = typer.Option(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user