From 747e39bf55cfc19b6eeece3ca7c71bad98d92389 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 8 Sep 2023 17:39:11 +0300 Subject: [PATCH] meli: add print-used-paths subcommand Print all paths that meli creates/uses e.g. XDG data path and temp dir path. Signed-off-by: Manos Pitsidianakis --- meli/docs/meli.1 | 2 ++ meli/src/args.rs | 2 ++ meli/src/main.rs | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/meli/docs/meli.1 b/meli/docs/meli.1 index c54d8dc1..9bf1c2a9 100644 --- a/meli/docs/meli.1 +++ b/meli/docs/meli.1 @@ -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 diff --git a/meli/src/args.rs b/meli/src/args.rs index f470a797..f9bb14d6 100644 --- a/meli/src/args.rs +++ b/meli/src/args.rs @@ -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. diff --git a/meli/src/main.rs b/meli/src/main.rs index 70ad1abf..cd5b4c10 100644 --- a/meli/src/main.rs +++ b/meli/src/main.rs @@ -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 => {} }