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