Add subcommand to print config file location

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/356/head
Manos Pitsidianakis 2 months ago
parent 4e7b665672
commit 5af2e1ee66
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -65,12 +65,6 @@ Create configuration file in
.Pa path
if given, or at
.Pa $XDG_CONFIG_HOME/meli/config.toml
.It Cm edit-config
Edit configuration files with
.Ev EDITOR
or
.Ev VISUAL Ns
\&.
.It Cm test-config Op Ar path
Test a configuration file for syntax issues or missing options.
.It Cm man Op Ar page
@ -81,14 +75,26 @@ Install manual pages to the first location provided by
or
.Xr manpath 1 ,
unless you specify the directory as an argument.
.It Cm compiled-with
Print compile time feature flags of this binary.
.It Cm edit-config
Edit configuration files with
.Ev EDITOR
or
.Ev VISUAL Ns
\&.
.It Cm help
Prints help information or the help of the given subcommand(s).
.It Cm print-app-directories
Print all directories that
.Nm Ns
creates and uses.
.It Cm print-config-path
Print location of configuration file that will be loaded on normal app startup.
.It Cm print-default-theme
Print default theme keys and values in TOML syntax, to be used as a blueprint.
.It Cm print-loaded-themes
Print all loaded themes in TOML syntax.
.It Cm print-used-paths
Print all paths that are created and used.
.It Cm compiled-with
Print compile time feature flags of this binary.
.It Cm view
View mail from input file.
.El

@ -40,8 +40,11 @@ pub enum SubCommand {
PrintDefaultTheme,
/// print loaded themes in full to stdout and exit.
PrintLoadedThemes,
/// print all paths that meli creates/uses.
PrintUsedPaths,
/// print all directories that meli creates/uses.
PrintAppDirectories,
/// print location of configuration file that will be loaded on normal app
/// startup.
PrintConfigPath,
/// edit configuration files with `$EDITOR`/`$VISUAL`.
EditConfig,
/// create a sample configuration file with available configuration options.

@ -101,6 +101,11 @@ fn run_app(opt: Opt) -> Result<()> {
Some(SubCommand::EditConfig) => {
return subcommands::edit_config();
}
Some(SubCommand::PrintConfigPath) => {
let config_path = crate::conf::get_config_file()?;
println!("{}", config_path.display());
return Ok(());
}
#[cfg(not(feature = "cli-docs"))]
Some(SubCommand::Man(ManOpt {})) => {
return Err(Error::new("error: this version of meli was not build with embedded documentation (cargo feature `cli-docs`). You might have it installed as manpages (eg `man meli`), otherwise check https://meli-email.org"));
@ -122,7 +127,7 @@ fn run_app(opt: Opt) -> Result<()> {
return Ok(());
}
Some(SubCommand::View { .. }) => {}
Some(SubCommand::PrintUsedPaths) => {
Some(SubCommand::PrintAppDirectories) => {
println!(
"{}",
xdg::BaseDirectories::with_prefix("meli")

Loading…
Cancel
Save