Skip to content

Add inputs for regex, files, after_context, before_context, context #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ inputs:
description: 'If set, only warn, never error'
required: false
default: ''
regex:
description: "Regular expression that is used to find words"
required: false
default: ''
files:
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'
Expand Down
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ 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_REGEX}'"
if [ "x${INPUT_REGEX}" != "x" ]; then
command_args="${command_args} --regex ${INPUT_REGEX}"
fi
echo "Files or directories to check: '${INPUT_FILES}'"
if [ "x${INPUT_FILES}" != "x" ]; then
command_args="${command_args} --regex ${INPUT_FILES}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which argument are you trying to populate here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[spetrosi@fedora network]$ codespell --help | grep "\--regex" -A5
  -r REGEX, --regex REGEX
                        regular expression that is used to find words. By
                        default any alphanumeric character, the underscore,
                        the hyphen, and the apostrophe are used to build
                        words. This option cannot be specified together with
                        --write-changes.

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`
Expand Down