From 6f1edb099e85a76770df3dfde4059fca10584d3f Mon Sep 17 00:00:00 2001 From: Ragnar Petursson <74888286+kvikindi@users.noreply.github.com> Date: Thu, 14 Mar 2024 23:52:52 +0000 Subject: [PATCH 1/5] Update manual.md Added optional custom message in klipper macro. --- docs/manual.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/manual.md b/docs/manual.md index 7aad23a..2053f65 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -13,12 +13,17 @@ A klipper macro can look like this: ```yaml [gcode_macro update_git] gcode: - RUN_SHELL_COMMAND CMD=update_git_script + {% if params.MESSAGE|default("") != "" %} + RUN_SHELL_COMMAND CMD=update_git_script PARAMS="{params.MESSAGE}" + {% else %} + RUN_SHELL_COMMAND CMD=update_git_script + {% endif %} [gcode_shell_command update_git_script] command: bash -c "bash $HOME/klipper-backup/script.sh" timeout: 90.0 verbose: True ``` - -![klipper-backup-macro-image](https://i.imgur.com/UglWf6t.png) \ No newline at end of file +For a custom commit message using the klipper macro in console, type `update_git MESSAGE="YourMessage"`. +*** +![klipper-backup-macro-image](https://i.imgur.com/UglWf6t.png) From c243926b23c86330d8254d4364b1825059ba17cf Mon Sep 17 00:00:00 2001 From: Ragnar Petursson <74888286+kvikindi@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:53:35 +0000 Subject: [PATCH 2/5] Update manual.md Changed shell command to a more exact example --- docs/manual.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/manual.md b/docs/manual.md index 2053f65..0e76cbf 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -20,7 +20,7 @@ gcode: {% endif %} [gcode_shell_command update_git_script] -command: bash -c "bash $HOME/klipper-backup/script.sh" +command: bash /home/pi/klipper-backup/script.sh timeout: 90.0 verbose: True ``` From 0327fdab60883d15b58fa0322c2b70211642bc35 Mon Sep 17 00:00:00 2001 From: Ragnar Petursson <74888286+kvikindi@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:59:15 +0000 Subject: [PATCH 3/5] Update manual.md Clarified shell command example --- docs/manual.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/manual.md b/docs/manual.md index 0e76cbf..41c2325 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -20,10 +20,14 @@ gcode: {% endif %} [gcode_shell_command update_git_script] +# replace /home/pi/ with your actual directory. + command: bash /home/pi/klipper-backup/script.sh timeout: 90.0 verbose: True + ``` + For a custom commit message using the klipper macro in console, type `update_git MESSAGE="YourMessage"`. *** ![klipper-backup-macro-image](https://i.imgur.com/UglWf6t.png) From 879acada2419a57efc0af2436e93437085f4ea4e Mon Sep 17 00:00:00 2001 From: Ragnar Petursson <74888286+kvikindi@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:39:16 +0000 Subject: [PATCH 4/5] Apply suggestions from code review Looks positively perfect to me, and works on this end :) Co-authored-by: MrTylerjet --- docs/manual.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/manual.md b/docs/manual.md index 41c2325..0b19709 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -14,15 +14,13 @@ A klipper macro can look like this: [gcode_macro update_git] gcode: {% if params.MESSAGE|default("") != "" %} - RUN_SHELL_COMMAND CMD=update_git_script PARAMS="{params.MESSAGE}" + RUN_SHELL_COMMAND CMD=update_git_script PARAMS="'{params.MESSAGE}'" {% else %} RUN_SHELL_COMMAND CMD=update_git_script {% endif %} [gcode_shell_command update_git_script] -# replace /home/pi/ with your actual directory. - -command: bash /home/pi/klipper-backup/script.sh +command: bash -c "bash $HOME/klipper-backup/script.sh $0" timeout: 90.0 verbose: True From 7129a89d0b2b7f8d4e170a8c1ee5c925db9ed7bc Mon Sep 17 00:00:00 2001 From: Ragnar Petursson <74888286+kvikindi@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:51:36 +0000 Subject: [PATCH 5/5] Apply suggestions from code review LGTM, and works on this end :) Co-authored-by: MrTylerjet --- docs/manual.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/manual.md b/docs/manual.md index 0b19709..6fd4f45 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -13,13 +13,19 @@ A klipper macro can look like this: ```yaml [gcode_macro update_git] gcode: - {% if params.MESSAGE|default("") != "" %} - RUN_SHELL_COMMAND CMD=update_git_script PARAMS="'{params.MESSAGE}'" + {% set message = params.MESSAGE|default() %} + {% if message %} + RUN_SHELL_COMMAND CMD=update_git_script_message PARAMS="'{params.MESSAGE}'" {% else %} RUN_SHELL_COMMAND CMD=update_git_script {% endif %} [gcode_shell_command update_git_script] +command: bash -c "bash $HOME/klipper-backup/script.sh" +timeout: 90.0 +verbose: True + +[gcode_shell_command update_git_script_message] command: bash -c "bash $HOME/klipper-backup/script.sh $0" timeout: 90.0 verbose: True