Add manpage generation using xtask
* Add manpage generation. * Hide xtask compilation info. This changes the default behavior of the `cargo run` command for xtasks to hide the compilation info. This makes sense as xtask's are run as a program, and showing the compilation info every time clutters stdout with unrelated info. * Move ncspot's `clap::Command` to `lib.rs`. Moving the `clap::Command` used internally by ncspot to a library allows it to be easily shared between different packages (xtask and ncspot itself). This commit also reworks the xtasks to use clap for parsing the xtask arguments, which simplifies writing new xtasks. * Make `generate-manpage` `--output` optional. When more xtasks get added, it would make sense to have a `generate-all` subcommand that executes all xtasks, which wouldn't be able to have options for every separate subcommand. Therefore the `output` argument should be optional, and by default output to the `misc` directory which contains extra metadata files already. * Add packaging info to `README.md`. Update the README to include information for packagers. The information includes provided files as well as info on how to generate some of them.
This commit is contained in:
41
src/lib.rs
Normal file
41
src/lib.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use librespot_playback::audio_backend;
|
||||
|
||||
pub const AUTHOR: &str = "Henrik Friedrichsen <henrik@affekt.org> and contributors";
|
||||
|
||||
/// Return the [Command](clap::Command) that models the program's command line arguments. The
|
||||
/// command can be used to parse the actual arguments passed to the program, or to automatically
|
||||
/// generate a man page using clap's mangen package.
|
||||
pub fn program_arguments() -> clap::Command {
|
||||
let backends = {
|
||||
let backends: Vec<&str> = audio_backend::BACKENDS.iter().map(|b| b.0).collect();
|
||||
format!("Audio backends: {}", backends.join(", "))
|
||||
};
|
||||
|
||||
clap::Command::new("ncspot")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author(AUTHOR)
|
||||
.about("cross-platform ncurses Spotify client")
|
||||
.after_help(backends)
|
||||
.arg(
|
||||
clap::Arg::new("debug")
|
||||
.short('d')
|
||||
.long("debug")
|
||||
.value_name("FILE")
|
||||
.help("Enable debug logging to the specified file"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::new("basepath")
|
||||
.short('b')
|
||||
.long("basepath")
|
||||
.value_name("PATH")
|
||||
.help("custom basepath to config/cache files"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::new("config")
|
||||
.short('c')
|
||||
.long("config")
|
||||
.value_name("FILE")
|
||||
.help("Filename of config file in basepath")
|
||||
.default_value("config.toml"),
|
||||
)
|
||||
}
|
||||
36
src/main.rs
36
src/main.rs
@@ -12,14 +12,13 @@ use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use clap::{Arg, Command as ClapCommand};
|
||||
use cursive::event::EventTrigger;
|
||||
use cursive::traits::Nameable;
|
||||
use librespot_core::authentication::Credentials;
|
||||
use librespot_core::cache::Cache;
|
||||
use librespot_playback::audio_backend;
|
||||
use log::{error, info, trace};
|
||||
|
||||
use ncspot::program_arguments;
|
||||
#[cfg(unix)]
|
||||
use signal_hook::{consts::SIGHUP, consts::SIGTERM, iterator::Signals};
|
||||
|
||||
@@ -130,38 +129,7 @@ lazy_static!(
|
||||
fn main() -> Result<(), String> {
|
||||
register_backtrace_panic_handler();
|
||||
|
||||
let backends = {
|
||||
let backends: Vec<&str> = audio_backend::BACKENDS.iter().map(|b| b.0).collect();
|
||||
format!("Audio backends: {}", backends.join(", "))
|
||||
};
|
||||
let matches = ClapCommand::new("ncspot")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("Henrik Friedrichsen <henrik@affekt.org> and contributors")
|
||||
.about("cross-platform ncurses Spotify client")
|
||||
.after_help(backends)
|
||||
.arg(
|
||||
Arg::new("debug")
|
||||
.short('d')
|
||||
.long("debug")
|
||||
.value_name("FILE")
|
||||
.help("Enable debug logging to the specified file"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("basepath")
|
||||
.short('b')
|
||||
.long("basepath")
|
||||
.value_name("PATH")
|
||||
.help("custom basepath to config/cache files"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("config")
|
||||
.short('c')
|
||||
.long("config")
|
||||
.value_name("FILE")
|
||||
.help("Filename of config file in basepath")
|
||||
.default_value("config.toml"),
|
||||
)
|
||||
.get_matches();
|
||||
let matches = program_arguments().get_matches();
|
||||
|
||||
if let Some(filename) = matches.get_one::<String>("debug") {
|
||||
setup_logging(filename).expect("can't setup logging");
|
||||
|
||||
Reference in New Issue
Block a user