Add method to manually add artist metadata #85

Merged
wojtek merged 16 commits from 55---add-method-to-manually-add-artist-metadata into main 2024-01-10 22:33:58 +01:00
Showing only changes of commit 3a266c0ec5 - Show all commits

View File

@ -1,6 +1,6 @@
use paste::paste;
use std::path::PathBuf;
use structopt::StructOpt;
use structopt::{clap::AppSettings, StructOpt};
use musichoard::{
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
@ -11,20 +11,23 @@ use musichoard::{
type MH = MusicHoard<NoLibrary, JsonDatabase<JsonDatabaseFileBackend>>;
#[derive(StructOpt, Debug)]
#[structopt(about = "mh-edit: edit the MusicHoard database",
global_settings=&[AppSettings::DeriveDisplayOrder])]
struct Opt {
#[structopt(subcommand)]
category: Category,
#[structopt(
long = "database",
name = "database file path",
default_value = "database.json"
)]
database_file_path: PathBuf,
#[structopt(subcommand)]
category: Category,
}
#[derive(StructOpt, Debug)]
enum Category {
#[structopt(about = "Edit artist information")]
Artist(ArtistCommand),
}
@ -38,38 +41,51 @@ impl Category {
#[derive(StructOpt, Debug)]
enum ArtistCommand {
#[structopt(about = "Add a new artist to the collection")]
New(ArtistValue),
#[structopt(about = "Delete an artist from the collection")]
Delete(ArtistValue),
#[structopt(name = "musicbrainz")]
#[structopt(name = "musicbrainz", about = "Edit the MusicBrainz URL of an artist")]
MusicBrainz(UrlCommand<SingleUrlValue>),
#[structopt(name = "musicbutler")]
#[structopt(name = "musicbutler", about = "Edit the MusicButler URL of an artist")]
MusicButler(UrlCommand<MultiUrlValue>),
#[structopt(about = "Edit the Bandcamp URL of an artist")]
Bandcamp(UrlCommand<MultiUrlValue>),
#[structopt(about = "Edit the Qobuz URL of an artist")]
Qobuz(UrlCommand<SingleUrlValue>),
}
#[derive(StructOpt, Debug)]
struct ArtistValue {
#[structopt(help = "The name of the artist")]
artist: String,
}
#[derive(StructOpt, Debug)]
enum UrlCommand<T: StructOpt> {
#[structopt(about = "Add URL(s) without overwriting existing values")]
Add(T),
#[structopt(about = "Remove the provided URL(s)")]
Remove(T),
#[structopt(about = "Set the provided URL(s) overwriting any previous values")]
Set(T),
#[structopt(about = "Clear all URL(s)")]
Clear(ArtistValue),
}
#[derive(StructOpt, Debug)]
struct SingleUrlValue {
#[structopt(help = "The name of the artist")]
artist: String,
#[structopt(help = "The URL")]
url: String,
}
#[derive(StructOpt, Debug)]
struct MultiUrlValue {
#[structopt(help = "The name of the artist")]
artist: String,
#[structopt(help = "The list of URLs")]
urls: Vec<String>,
}