meli: add print-used-paths subcommand
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (pull_request) Successful in 21m42s Details
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (push) Successful in 10m2s Details

Print all paths that meli creates/uses e.g. XDG data path and temp dir
path.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/299/head
Manos Pitsidianakis 2023-09-08 17:39:11 +03:00
parent 9b9c38f769
commit 747e39bf55
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
3 changed files with 20 additions and 0 deletions

View File

@ -79,6 +79,8 @@ Print documentation page and exit (Piping to a pager is recommended).
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 meli creates/uses.
.It Cm compiled-with
Print compile time feature flags of this binary.
.It Cm view

View File

@ -65,6 +65,8 @@ pub enum SubCommand {
PrintDefaultTheme,
/// print loaded themes in full to stdout and exit.
PrintLoadedThemes,
/// print all paths that meli creates/uses.
PrintUsedPaths,
/// edit configuration files with `$EDITOR`/`$VISUAL`.
EditConfig,
/// create a sample configuration file with available configuration options.

View File

@ -117,6 +117,22 @@ fn run_app(opt: Opt) -> Result<()> {
return Ok(());
}
Some(SubCommand::View { .. }) => {}
Some(SubCommand::PrintUsedPaths) => {
println!(
"{}",
xdg::BaseDirectories::with_prefix("meli")
.expect(
"Could not find your XDG directories. If this is unexpected, please \
report it as a bug."
)
.get_data_file("")
.display()
);
let mut temp_dir = std::env::temp_dir();
temp_dir.push("meli");
println!("{}", temp_dir.display());
return Ok(());
}
None => {}
}