From 8d608529f3605221a5d0be090cfcf4dc6976fee8 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Wed, 5 Feb 2025 18:45:10 +0100 Subject: [PATCH 1/5] Add regex input --- action.yml | 4 ++++ entrypoint.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/action.yml b/action.yml index 59e4372..c64e244 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,10 @@ inputs: description: 'If set, only warn, never error' required: false default: '' + regex: + description: "Regular expression that is used to find words" + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 7c3d4ed..d2e043d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -44,6 +44,10 @@ echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'" if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}" fi +echo "Regular expression that is used to find words: '${INPUT_SKIP}'" +if [ "x${INPUT_REGEX}" != "x" ]; then + command_args="${command_args} --regex ${INPUT_REGEX}" +fi echo "Resulting CLI options ${command_args}" exec 5>&1 res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1` From 7e7899b0c97f43d29ae064afefdc73e757814c26 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Wed, 5 Feb 2025 18:45:25 +0100 Subject: [PATCH 2/5] Add files input --- action.yml | 4 ++++ entrypoint.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/action.yml b/action.yml index c64e244..ad3a4c7 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,10 @@ inputs: description: "Regular expression that is used to find words" required: false default: '' + files: + description: "Files or directories to check" + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index d2e043d..8c9f62f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -48,6 +48,10 @@ echo "Regular expression that is used to find words: '${INPUT_SKIP}'" if [ "x${INPUT_REGEX}" != "x" ]; then command_args="${command_args} --regex ${INPUT_REGEX}" fi +echo "Files or directories to check: '${INPUT_SKIP}'" +if [ "x${INPUT_FILES}" != "x" ]; then + command_args="${command_args} --regex ${INPUT_FILES}" +fi echo "Resulting CLI options ${command_args}" exec 5>&1 res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1` From 8da81ddc4cca0e22ab83de98cea81032cbd927b2 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Thu, 6 Feb 2025 09:07:30 +0100 Subject: [PATCH 3/5] Add after_context, before_context, context inputs --- action.yml | 12 ++++++++++++ entrypoint.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/action.yml b/action.yml index ad3a4c7..d02b84c 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,18 @@ inputs: description: "Files or directories to check" required: false default: '' + after_context: + description: "Print a number of lines of trailing context" + required: false + default: '' + before_context: + description: "Print a number of lines of leading context" + required: false + default: '' + context: + description: "Print a number of lines of surrounding context" + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 8c9f62f..bd6a73c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -52,6 +52,18 @@ echo "Files or directories to check: '${INPUT_SKIP}'" if [ "x${INPUT_FILES}" != "x" ]; then command_args="${command_args} --regex ${INPUT_FILES}" fi +echo "Print a number of lines of trailing context: '${INPUT_AFTER_CONTEXT}'" +if [ "x${INPUT_AFTER_CONTEXT}" != "x" ]; then + command_args="${command_args} --after-context ${INPUT_AFTER_CONTEXT}" +fi +echo "Print a number of lines of leading context: '${INPUT_BEFORE_CONTEXT}'" +if [ "x${INPUT_BEFORE_CONTEXT}" != "x" ]; then + command_args="${command_args} --before-context ${INPUT_BEFORE_CONTEXT}" +fi +echo "Print a number of lines of surrounding context: '${INPUT_CONTEXT}'" +if [ "x${INPUT_CONTEXT}" != "x" ]; then + command_args="${command_args} --context ${INPUT_CONTEXT}" +fi echo "Resulting CLI options ${command_args}" exec 5>&1 res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1` From 4d9b41203a58522254831d11669a8c911640fab0 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Thu, 6 Feb 2025 09:10:33 +0100 Subject: [PATCH 4/5] Add README entries --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 84597fc..7f3e681 100644 --- a/README.md +++ b/README.md @@ -135,3 +135,34 @@ uses: codespell-project/actions-codespell@v2 with: only_warn: 1 ``` + +### Parameter: regex + +Regular expression that is used to find words. + +This parameter is optional. + +### Parameter: files + +Files or directories to check. + +This parameter is optional. + +### Parameter: after_context + +Print a number of lines of trailing context. + +This parameter is optional. + +### Parameter: before_context + +Print a number of lines of leading context. + +This parameter is optional. + +### Parameter: context + +Print a number of lines of surrounding context. + +This parameter is optional. + From fc07c24cacc9b2a5cf8341b4ad11c5ac1f2d69d6 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Thu, 6 Feb 2025 09:11:26 +0100 Subject: [PATCH 5/5] Apply suggestions from code review --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index bd6a73c..5ee9dd8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -44,11 +44,11 @@ echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'" if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}" fi -echo "Regular expression that is used to find words: '${INPUT_SKIP}'" +echo "Regular expression that is used to find words: '${INPUT_REGEX}'" if [ "x${INPUT_REGEX}" != "x" ]; then command_args="${command_args} --regex ${INPUT_REGEX}" fi -echo "Files or directories to check: '${INPUT_SKIP}'" +echo "Files or directories to check: '${INPUT_FILES}'" if [ "x${INPUT_FILES}" != "x" ]; then command_args="${command_args} --regex ${INPUT_FILES}" fi