Skip to content

Commit

Permalink
New features in awk
Browse files Browse the repository at this point in the history
  • Loading branch information
simosathan9 committed Oct 22, 2024
1 parent 2867557 commit f7de951
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 105 deletions.
102 changes: 51 additions & 51 deletions bin/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
#!/bin/sh

# Run npm run check to perform checks before committing
npm run format-check

# If npm run check fails (returns non-zero exit code), exit with error
if [ $? -ne 0 ]; then
echo "npm run check failed, aborting commit."
echo "Run 'npm run prettier-fix' to fix formatting issues."
exit 1
fi

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi

# If there are whitespace errors, print the offending file names and fail.
#!/bin/sh

# Run npm run check to perform checks before committing
npm run format-check

# If npm run check fails (returns non-zero exit code), exit with error
if [ $? -ne 0 ]; then
echo "npm run check failed, aborting commit."
echo "Run 'npm run prettier-fix' to fix formatting issues."
exit 1
fi

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi

# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
50 changes: 37 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Blockly Demo: Unix</title>
<title>Ublocks</title>
<meta name="x-auth-token" content="" />
<script src="https://unpkg.com/blockly@latest/blockly_compressed.js"></script>
<script src="https://unpkg.com/blockly@latest/blocks_compressed.js"></script>
Expand Down Expand Up @@ -85,6 +85,7 @@
<script src="blocks/xargsBlock.js"></script>
<script src="blocks/conditionActionBlock.js"></script>
<script src="blocks/conditionBlock.js"></script>
<script src="blocks/arrayCreateBlock.js"></script>
<!-- END OF BLOCK DEFINITION -->
<script>
document.addEventListener('DOMContentLoaded', () => {
Expand Down Expand Up @@ -292,6 +293,11 @@
colourSecondary: '#ff0000',
colourTertiary: '#C5EAFF'
},
Tables: {
colourPrimary: '#260',
colourSecondary: '#ff0000',
colourTertiary: '#C5EAFF'
},
'Other Commands': {
colourPrimary: '#009688',
colourSecondary: '#ff0000',
Expand Down Expand Up @@ -449,14 +455,13 @@
name: [MSG.FIELD_PROCESSING],
colour: '#3B7C09',
contents: [
{ kind: 'block', type: 'beginEnd' },
{ kind: 'block', type: 'conditionAction' },
//{ kind: 'block', type: 'beginEnd' },
{ kind: 'block', type: 'awk' },
{ kind: 'block', type: 'condOutput' },
{ kind: 'block', type: 'conditionAction' },
{ kind: 'block', type: 'column' },
{ kind: 'block', type: 'NR' },
{ kind: 'block', type: 'NF' },
{ kind: 'block', type: 'xargs' },
// { kind: 'block', type: 'xargs' },
{ kind: 'block', type: 'condition' },
{
kind: 'category',
Expand Down Expand Up @@ -485,20 +490,16 @@
kind: 'category',
name: [MSG.LOGIC],
colour: '210',
contents: [
{ kind: 'block', type: 'controls_if' },
{ kind: 'block', type: 'logic_compare' },
{ kind: 'block', type: 'logic_operation' },
{ kind: 'block', type: 'logic_negate' }
]
contents: [{ kind: 'block', type: 'controls_if' }]
},
{
kind: 'category',
name: [MSG.LOOPS],
colour: '120',
contents: [
{ kind: 'block', type: 'controls_whileUntil' },
{ kind: 'block', type: 'controls_forEach' }
{ kind: 'block', type: 'controls_forEach' },
{ kind: 'block', type: 'controls_for' }
]
},
{
Expand Down Expand Up @@ -533,9 +534,32 @@
},
{
kind: 'category',
name: [MSG.VARIABLES],
name: [MSG.VARIABLES], // Use the translated message for "Variables"
colour: '330',
custom: 'VARIABLE'
},
{
kind: 'category',
name: 'Lists', // Reference to the translated message for "Lists"
colour: '260',
contents: [
{
kind: 'block',
type: 'lists_create_with' // Block for creating a list with items
},
{
kind: 'block',
type: 'lists_getIndex' // Block for getting an item from a list
},
{
kind: 'block',
type: 'lists_setIndex' // Block for setting an item in a list
}
//{
// kind: 'block',
// type: 'lists_getSublist' // Block for getting a sublist from a list
//}
]
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion public/blocks/arrayCreateBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var arrayCreateBlock = {
}
],
output: 'Array',
style: 'list_blocks',
style: 'Field Processing',
nextStatement: 'Action',
helpUrl: '%{BKY_ARRAY_CREATE_WITH_HELPURL}',
tooltip: '%{BKY_ARRAY_CREATE_WITH_TOOLTIP}',
Expand Down
3 changes: 2 additions & 1 deletion public/blocks/conditionActionBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var conditionActionBlock = {
message0: '%{BKY_CONDITION_ACTION_COND} %1',
args0: [
{
type: 'input_statement',
type: 'input_value',
name: 'COND'
}
],
Expand All @@ -23,6 +23,7 @@ var conditionActionBlock = {
helpUrl: '%{BKY_CONDITION_ACTION_HELPURL}', // URL to further information or documentation.
generateCommand: function (block) {
var cond = block.getInputTargetBlock('COND');
console.log('cond:', cond);
var condCommand = '';
if (cond !== null) {
condCommand = handleBlockByType(cond);
Expand Down
7 changes: 5 additions & 2 deletions public/blocks/conditionBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ var conditionBlock = {
['<', '<'],
['<=', '<='],
['>', '>'],
['>=', '>=']
['>=', '>='],
['&& (AND)', '&&'],
['|| (OR)', '||'],
['! (NOT)', '!']
]
}
],
Expand All @@ -33,7 +36,7 @@ var conditionBlock = {
}
],
style: 'Field Processing',
previousStatement: null,
output: null,
generateCommand: function (block) {
var awkCondition = '';
const leftPartBlock = block.getInputTargetBlock('left_part');
Expand Down
6 changes: 1 addition & 5 deletions public/blocks/cutBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ var cutBlock = {
previousStatement: 'Action',
nextStatement: 'Action',
tooltip: '%{BKY_CUT_TOOLTIP}',
extensions: [
'cut_validation',
'integer_validation',
'disallow_multiple_filenames'
],
extensions: ['cut_validation', 'integer_validation'],
helpUrl: '%{BKY_CUT_HELPURL}', // URL to further information or documentation.

generateCommand: function (block) {
Expand Down
Binary file modified public/img/combine_files.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/extract_columns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/remove_duplicate_lines_and_sort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f7de951

Please sign in to comment.