chshersh / tool-sync

🧰 Download pre-built binaries of all your favourite tools with a single command
https://crates.io/crates/tool-sync
Mozilla Public License 2.0
69 stars 16 forks source link

Implement the '--path' option for the 'default-config' command #109

Closed chshersh closed 1 year ago

chshersh commented 1 year ago

Instead of outputting the config content, it should output the path to the default config location.

Relevant code parts:

https://github.com/chshersh/tool-sync/blob/df7d4768c9cff2a91616bd9686bc928a52fc8c10/src/config/cli.rs#L21-L22

https://github.com/chshersh/tool-sync/blob/df7d4768c9cff2a91616bd9686bc928a52fc8c10/src/lib.rs#L21

https://github.com/chshersh/tool-sync/blob/df7d4768c9cff2a91616bd9686bc928a52fc8c10/src/lib.rs#L29-L44

zixuan-x commented 1 year ago

Just to clarify, when the user type tool default-config --path, we should just print the path that gets returned by resolve_config_path()?

chshersh commented 1 year ago

@zixuanzhang-x Yes, you're correct, we should print only the path to stdout. But it shouldn't be the result of resolve_config_path().

I propose to move the following part into a separate function like get_default_config_path() and use it in the --path option and in the resolve_config_path() functions.

match dirs::home_dir() { 
             Some(home_path) => { 
                 let mut path = PathBuf::new(); 
                 path.push(home_path); 
                 path.push(DEFAULT_CONFIG_PATH); 
                 path 
             }