Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Closes automated installation #2 #8

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

Merged
merged 10 commits into from
Jul 11, 2020
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This is a basic workflow to help you get started with Actions

name: CI


on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Makefile tests
run: |
make samples
make tests
205 changes: 205 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# VIM Header Composer Examples

> **Warning:** this file was generated by the execution of `make samples`, manual changes possible will be overwritten.

Instead of using the characters and the standard format you can set the string to process using styles as seen below.




------
### Using 'sides'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:sides;Example using 'sides'."`.
```
⎡ ⎤
⎢ Example using 'sides'. ⎥
⎣ ⎦
```



------
### Using 'prettybox'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:prettybox;Example using 'prettybox'."`.
```
┌────────────────────────────┐
│ Example using 'prettybox'. │
└────────────────────────────┘
```



------
### Using 'pretty'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:pretty;Example using 'pretty'."`.
```
┌─────────────────────────┐
│ Example using 'pretty'. │
└─────────────────────────┘
```



------
### Using 'quotes'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:quotes;Example using 'quotes'."`.
```
"
Example using 'quotes'.
"
```



------
### Using 'docblock'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:docblock;Example using 'docblock'."`.
```
/**
* Example using 'docblock'.
**/
```



------
### Using 'cccomment'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:cccomment;Example using 'cccomment'."`.
```
/**
** Example using 'cccomment'.
**/
```



------
### Using 'ccomment'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:ccomment;Example using 'ccomment'."`.
```
/*
* Example using 'ccomment'.
*/
```



------
### Using 'lcomment'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:lcomment;Example using 'lcomment'."`.
```
//
// Example using 'lcomment'.
//
```



------
### Using 'box'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:box;Example using 'box'."`.
```
+----------------------+
| Example using 'box'. |
+----------------------+
```



------
### Using 'star'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:star;Example using 'star'."`.
```
*************************
* Example using 'star'. *
*************************
```



------
### Using 'stars'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:stars;Example using 'stars'."`.
```
**************************
* Example using 'stars'. *
**************************
```



------
### Using 'asterisk'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:asterisk;Example using 'asterisk'."`.
```
*****************************
* Example using 'asterisk'. *
*****************************
```



------
### Using 'ernjs'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:ernjs;Example using 'ernjs'."`.
```
################################
#### Example using 'ernjs'. ####
################################
```



------
### Using 'ernando'

Example using `#!/usr/bin/env bash

./vhc <<< "vhc:ernando;Example using 'ernando'."`.
```
##################################
#### Example using 'ernando'. ####
##################################
```



136 changes: 136 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#
# λ::Makefile
#
# For further information see `README.md`.

PREFIX?= /bin
TARGET?= ~/.local
SOURCE?= vhc
NULL ?= /dev/null
VIMRC = ~/.vimrc

INSTALL= $(TARGET)$(PREFIX)
VIMCONF= echo 'map <F2> :!vhc' >> $(VIMRC)

ifneq (,$(DESTDIR))
TARGET =$(DESTDIR)
endif


CMD = "\\e[1m%-10s\\e[0m%s\n"
STR = "\\e[0;2;3m%s\\e[0m\n"
HLP = sed -E 's/(`.*`)/\\e[1m\1\\e[0m/'


DEFAULT: help



backup:
@\
cp $(VIMRC) $(VIMRC)_$(shell date +'%Y%m%d%H%M%S')


#
install: backup # Installs application.
@\
mkdir -p $(INSTALL) 2>$(NULL) ; \
install -D $(SOURCE) $(INSTALL)/$(SOURCE) ; \
chmod +x $(INSTALL)/$(SOURCE) ; \
echo Installed into '$(INSTALL)/$(SOURCE)'

@\
LINE=$$(cat $(VIMRC)"" | grep -n "$(SOURCE)"\
| awk -F':' '''{ print($$1); }'); (( sed -i \
"$${LINE},1 s/^[\"| ]*//g" $(VIMRC)))

@\
VIM=$$(cat $(VIMRC)"" | grep "$(SOURCE)") ; \
[ -e $(INSTALL)/$(SOURCE) -a -z "$${VIM}" ] \
&& ((echo 'Configuring VIM'; $(VIMCONF) )) \
|| ((echo "VIM configured with '$${VIM}'"))



uninstall: backup # Uninstalls application.
@\
rm -Rf $(INSTALL)/$(SOURCE); \
echo "'$(INSTALL)/$(SOURCE)' removed."

@\
LINE=$$(cat $(VIMRC) | grep -n "$(SOURCE)" | awk -F':' '{print($$1)}'); \
sed -i "$${LINE},1 s/^/\" /" $(VIMRC)


#
help: # Shows this help.
@\
echo """"""""""""""""""""""""""" \
$$(awk 'BEGIN { FS=":.*?#" } \
/^(\w+:.*|)#/ { \
gsub("^( : |)#( |)", """""""" ); \
LEN=length($$2); COND=(LEN < 1); \
FORMAT=(COND ? $(STR) : $(CMD)); \
printf(FORMAT, $$1, """"""$$2 ); \
}' $(MAKEFILE_LIST) | ($(HLP)))"


#
samples: # Build tests and EXAMPLES.md using possible style options.
@\
mkdir -p tests; \
NUM(){ cat vhc | grep -n "$${1}OPTIONS" | awk -F':' '{print($$1)}'; }; \
INI=$$(NUM "# "); \
END=$$(NUM "#/"); \
MAX=$$(cat vhc | wc -l); \
GET=$$((MAX - INI - 1)); \
LEN=$$((END - INI - 3)); \
TARGET=EXAMPLES.md \
OPTIONS=$$(cat vhc \
| tail -n"$${GET}" \
| head -n"$${LEN}" \
| sed -E 's/^\s+([a-z0-9\-\|\*]*)\).*$$/\1/; s/\|/ /g; s/\*//g'); \
echo "# VIM Header Composer Examples\n\n" \
"> **Warning:** this file was generated by the execution of \`make samples\`, manual changes possible will be overwritten.\n\n" \
"Instead of using the characters and the standard format you can set the string to process using styles as seen below.\n\n\n\n" \
> $$TARGET; \
for opt in $$OPTIONS; \
do TEST=tests/testing_style_$${opt}.sh; \
echo "Creating test \e[1m$${opt}\e[0m.."; \
echo "------\n### Using '$${opt}'\n" >> $$TARGET; \
echo "#!/usr/bin/env bash\n\n""./vhc <<< \"vhc:"$${opt}";Example using '$${opt}'.\"" > $${TEST}; \
echo "Example using \`$$(cat $${TEST})\`.\n\`\`\`" >> $$TARGET; \
echo "vhc:$${opt};Example using '$${opt}'." | ./vhc > $${TEST}.result;\
echo "$$(cat $${TEST}.result)\n\`\`\`\n\n\n" >> $$TARGET; \
done


#
.PHONY: tests
tests: # Execute tests.
@\
gMD5(){ cat $$1 | md5sum | awk '{print($$1)}'; };\
for each in ./tests/*.sh; \
do bash "$${each}" >.test ; \
TESTS=$$(echo $${each} | sed -E 's/_/ /g; s/\.sh$$//g; s/^.*\///'); \
printf "%*s%s\r%s" 5 "" "$${TESTS}"; \
VALID=$$(gMD5 ".test"); \
CHECK=$$(gMD5 $${each}.result); \
VALUE="\e[31mFail\e[0m"; \
[ "$${VALID}" = "$${CHECK}" ] \
&& VALUE="\e[32mDone\e[0m" \
|| FAIL=true; \
echo "$${VALUE}"; \
done; \
rm -Rf .test; \
[ -z $${FAIL} ] || exit 1



clear: # Clear.
@\
rm -Rf tests .test

#
%:
@:
Loading