Skip to content

Commit

Permalink
Rework command line docs
Browse files Browse the repository at this point in the history
  • Loading branch information
theirix committed Jan 4, 2024
1 parent c556828 commit fe43af2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0.72"
atty = "0.2.14"
clap = { version = "4.4.13", features = ["derive"] }
directories = "5.0.1"
env_logger = { version = "0.10.0", features = ["color"] }
humantime = "2.1.0"
Expand All @@ -16,7 +17,6 @@ md5 = "0.7.0"
reqwest = { version = "0.11.18", features = ["json", "blocking"] }
serde = { version = "1.0.171", features = ["derive"] }
serde_json = "1.0.103"
structopt = { version = "0.3.26", features = ["color"] }
thiserror = "1.0.43"
time = { version = "0.3.23", features = ["macros", "formatting", "local-offset"] }
toml = "0.7.6"
Expand Down
29 changes: 16 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,59 @@ mod utils;
use crate::auth::authenticate;
use crate::scrobbler::{scrobble_album, scrobble_track, scrobble_url};
use anyhow::Context;
use clap::Parser;
use env_logger::Env;
use log::{error, info};
use structopt::StructOpt;
use time::Duration;

#[derive(Debug, Clone, StructOpt)]
#[derive(Debug, Clone, Parser)]
enum CliArgs {
#[command(about = "Scrobble album of artist or track of artist to Last.fm")]
Scrobble {
/// Artist name
#[structopt(long)]
#[arg(long)]
artist: String,

/// Album name
#[structopt(long)]
#[arg(long)]
album: Option<String>,

/// Track name
#[structopt(long)]
#[arg(long)]
track: Option<String>,

/// Dry run mode (no writes done)
#[structopt(short, long)]
#[arg(short, long)]
dryrun: bool,

/// Start time
#[structopt(long)]
#[arg(long)]
start: Option<String>,
},

#[command(about = "Scrobble album from given URL to Last.fm")]
ScrobbleUrl {
/// Last.fm album page URL
#[structopt(long)]
#[arg(long)]
url: String,

/// Dry run mode (no writes done)
#[structopt(short, long)]
#[arg(short, long)]
dryrun: bool,

/// Start time
#[structopt(long)]
#[arg(long)]
start: Option<String>,
},

#[command(about = "Authenticate with Last.fm desktop API")]
Auth {
/// API key
#[structopt(long)]
#[arg(long)]
api_key: String,

/// Secret key
#[structopt(long)]
#[arg(long)]
secret_key: String,
},
}
Expand Down Expand Up @@ -116,7 +119,7 @@ fn main() -> Result<(), anyhow::Error> {
.format_timestamp(None)
.init();

let cli_args = CliArgs::from_args();
let cli_args = CliArgs::parse();
let result = run(cli_args);
match result {
Ok(_) => {
Expand Down

0 comments on commit fe43af2

Please sign in to comment.