From 9492ba66b273325db34e393a50965c13cc44af4c Mon Sep 17 00:00:00 2001 From: afterlifepro Date: Fri, 5 Sep 2025 23:34:11 +0100 Subject: [PATCH] Better help logs --- src/main.rs | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 192f5e6..109e19d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,38 @@ fn help() { - println!("\n\nHELP: tangled-on-commit\n\n") + println!("Help: tangled-on-commit +Listen for commits on a specified repository and execute a shell command. + +CLI Arguments: + `tangled-on-commit (-h | --help)` + Displays this message + + `tangled-on-commit` + No specified handle, repo, or command. Falls back to config/env + + `tangled-on-commit SHELL` + Uses config/env for handle and repo + + `tangled-on-commit @HANDLE SHELL` + Uses config/env for repo + + `tangled-on-commit REPO SHELL` + Uses config/env for handle + + `tangled-on-commit @HANDLE/REPO SHELL` + `tangled-on-commit HANDLE REPO SHELL` + No config/env + +JSON: + Loads the file `tangled-on-commit.json` from cwd if it exists. + Reads keys \"handle\", \"repo_name\", and \"shell\". + Unknown keys are ignored and any key can be ommitted + JSON is used if the arguments aren't passed to the CLI + +Env: + Loads the environment variables `TANGLED_ON_COMMIT_HANDLE` and `TANGLED_ON_COMMIT_REPO_NAME` + Shell cannot be set by environment variables. + Env variables are used if relevant keys are ommitted an arguments aren't passed to the CLI. +") } #[derive(Debug)] @@ -164,7 +197,11 @@ fn load_config() -> Result { // couldnt resolve every value // print an error and quit - println!("@{handle:?}/{repo_name:?}: {shell:?}"); + println!("Unable to find a value for every setting. Missing values for:"); + if handle.is_none() {println!("- handle");} + if repo_name.is_none() {println!("- repo_name");} + if shell.is_none() {println!("- shell");} + println!("\nRun `tangled-on-commit --help` to see the help message"); return Err(()); } -- 2.51.2