From 3a266c0ec534c43dbc565cf89d0023722add3961 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Wed, 10 Jan 2024 19:30:31 +0100 Subject: [PATCH] Add docstrings to the mh-edit command --- src/bin/mh-edit.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/bin/mh-edit.rs b/src/bin/mh-edit.rs index 5b717f3..6025ba2 100644 --- a/src/bin/mh-edit.rs +++ b/src/bin/mh-edit.rs @@ -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>; #[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), - #[structopt(name = "musicbutler")] + #[structopt(name = "musicbutler", about = "Edit the MusicButler URL of an artist")] MusicButler(UrlCommand), + #[structopt(about = "Edit the Bandcamp URL of an artist")] Bandcamp(UrlCommand), + #[structopt(about = "Edit the Qobuz URL of an artist")] Qobuz(UrlCommand), } #[derive(StructOpt, Debug)] struct ArtistValue { + #[structopt(help = "The name of the artist")] artist: String, } #[derive(StructOpt, Debug)] enum UrlCommand { + #[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, }