Namespace src/Filters
src/Filters
Overview
Directory src/Filters
file source src/Filters/bashFrameworkFunctions.sh
Filters::bashFrameworkFunctions
allows to match a bash framework function based on the naming convention
Arguments
- … (files:String[]): the files in which bash framework functions will be extracted
Environment variables
- PREFIX (String): an eventual prefix you would like to match
- FRAMEWORK_FUNCTIONS_IGNORE_REGEXP (String): this filter does not use this variable
Exit codes
- 0: if match or no match
- 2: if grep fails for other reasons
Input on stdin
- you can alternatively provide content to filter via stdin
Output on stdout
- the list of bash framework function detected
Warnings
- this filter could extract bash framework functions that are actually commented in the source file
- use FRAMEWORK_FUNCTIONS_IGNORE_REGEXP from .framework-config to filter unwanted functions
See also
src/Filters/camel2snakeCase.sh
file source src/Filters/camel2snakeCase.sh
Filters::camel2snakeCase
transform camel case format to snake case
Example
TEST => test
camelCase2SnakeCase => camel_case2snake_case
origin/featureTest/Tools-1456 => origin/feature_test/tools_1456
# the function is clever enough with some strange case (not really camel case)
featureTEST/TOOLS-1456 => feature_test/tools_1456
innovation/vuecli-with-web => innovation/vuecli_with_web
@stdin the string to filter
@stdout the string converted to snake case
src/Filters/commentLines.sh
file source src/Filters/commentLines.sh
Filters::commentLines
remove comment lines from input or files provided as arguments
Arguments
- … (files:String[]): (optional) the files to filter
Environment variables
- commentLinePrefix (String): the comment line prefix (default value: #)
Exit codes
- 0: if lines filtered or not
- 2: if grep fails for any other reasons than not found
Input on stdin
- the file as stdin to filter (alternative to files argument)
Output on stdout
- the filtered lines
src/Filters/firstField.sh
file source src/Filters/firstField.sh
Filters::firstField
equivalent of awk ‘NR==1{print $1}’ allows to retrieve the first field of a piped input
src/Filters/optimizeShFile.sh
file source src/Filters/optimizeShFile.sh
Filters::optimizeShFile
remove shebang line, empty lines and comment lines (just the ones with spaces or not before the # Note: comment after command is more difficult to remove because complicated case could occur Eg: # inside strings like in “sed -E -e ’s/#/…..”
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the lines filtered
src/Filters/removeAnsiCodes.sh
file source src/Filters/removeAnsiCodes.sh
Filters::removeAnsiCodes
remove ansi codes from input or files given as argument
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the filtered content
See also
src/Filters/removeDuplicatedShebangs.sh
file source src/Filters/removeDuplicatedShebangs.sh
Filters::removeDuplicatedShebangs
remove all shebangs except the first one
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the filtered content
src/Filters/removeEmptyLines.sh
file source src/Filters/removeEmptyLines.sh
Filters::removeEmptyLines
remove empty lines and lines containing only spaces
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the filtered content
src/Filters/removeEmptyLinesFromBeginning.sh
file source src/Filters/removeEmptyLinesFromBeginning.sh
Filters::removeEmptyLinesFromBeginning
remove empty lines and lines containing only spaces and stops since a non empty line is found
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the filtered content
src/Filters/removeExternalQuotes.sh
file source src/Filters/removeExternalQuotes.sh
Filters::removeExternalQuotes
remove quotes (" or ‘) from stdin
Example
echo '"TEST"' => "TEST"
echo '"TEST"' | Filters::removeExternalQuotes # => TEST
@arg $@ files:String[] the files to filter
@exitcode * if one of the filter command fails
@stdin you can use stdin as alternative to files argument
@stdout the filtered content
src/Filters/toLowerCase.sh
file source src/Filters/toLowerCase.sh
Filters::toLowerCase
convert text to lower case
Arguments
- $1 (str:String): the string to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to str argument
Output on stdout
- the filtered content
src/Filters/toUpperCase.sh
file source src/Filters/toUpperCase.sh
Filters::toUpperCase
convert text to upper case
Arguments
- $1 (str:String): the string to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to str argument
Output on stdout
- the filtered content
src/Filters/trimEmptyLines.sh
file source src/Filters/trimEmptyLines.sh
Filters::trimEmptyLines
remove all empty lines
- at the beginning of the file before non empty line
- at the end of the file after last non empty line
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the filtered content
See also
src/Filters/trimString.sh
file source src/Filters/trimString.sh
Filters::trimString
remove leading and trailing spaces of a string
Arguments
- … (files:String[]): the files to filter
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to files argument
Output on stdout
- the filtered content
src/Filters/uniqUnsorted.sh
file source src/Filters/uniqUnsorted.sh
Filters::uniqUnsorted
uniq command need input file to be sorted here We are using awk that do not need file to be sorted to get uniq values iterates over each file and prints (default awk behavior) each unique line; only takes first value and ignores duplicates Note ! be careful of memory usage as each unique $0 is stored in an array
Exit codes
- if one of the filter command fails
Input on stdin
- you can use stdin as alternative to str argument
Output on stdout
- the filtered content