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

Skip to content

Commit ad7ad47

Browse files
Merge pull request #2 from jmurowaniecki/feature/installation
provides installation, improved documentation and more
2 parents 870e8ff + a42a27a commit ad7ad47

33 files changed

+517
-101
lines changed

.github/workflows/quality.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
14+
shellcheck:
15+
name: Shellcheck
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@master
19+
- name: Run ShellCheck
20+
uses: ludeeus/action-shellcheck@master
21+
22+
validate:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: Run Makefile tests
27+
run: |
28+
make samples
29+
make tests

EXAMPLES.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# VIM Header Composer Examples
2+
3+
> **Warning:** this file was generated by the execution of `make samples`, manual changes possible will be overwritten.
4+
5+
Instead of using the characters and the standard format you can set the string to process using styles as seen below.
6+
7+
8+
9+
10+
------
11+
### Using 'sides'
12+
13+
Example using `#!/usr/bin/env bash
14+
15+
./vhc <<< "vhc:sides;Example using 'sides'."`.
16+
```
17+
⎡ ⎤
18+
⎢ Example using 'sides'. ⎥
19+
⎣ ⎦
20+
```
21+
22+
23+
24+
------
25+
### Using 'prettybox'
26+
27+
Example using `#!/usr/bin/env bash
28+
29+
./vhc <<< "vhc:prettybox;Example using 'prettybox'."`.
30+
```
31+
┌────────────────────────────┐
32+
│ Example using 'prettybox'. │
33+
└────────────────────────────┘
34+
```
35+
36+
37+
38+
------
39+
### Using 'pretty'
40+
41+
Example using `#!/usr/bin/env bash
42+
43+
./vhc <<< "vhc:pretty;Example using 'pretty'."`.
44+
```
45+
┌─────────────────────────┐
46+
│ Example using 'pretty'. │
47+
└─────────────────────────┘
48+
```
49+
50+
51+
52+
------
53+
### Using 'quotes'
54+
55+
Example using `#!/usr/bin/env bash
56+
57+
./vhc <<< "vhc:quotes;Example using 'quotes'."`.
58+
```
59+
"
60+
Example using 'quotes'.
61+
"
62+
```
63+
64+
65+
66+
------
67+
### Using 'docblock'
68+
69+
Example using `#!/usr/bin/env bash
70+
71+
./vhc <<< "vhc:docblock;Example using 'docblock'."`.
72+
```
73+
/**
74+
* Example using 'docblock'.
75+
**/
76+
```
77+
78+
79+
80+
------
81+
### Using 'cccomment'
82+
83+
Example using `#!/usr/bin/env bash
84+
85+
./vhc <<< "vhc:cccomment;Example using 'cccomment'."`.
86+
```
87+
/**
88+
** Example using 'cccomment'.
89+
**/
90+
```
91+
92+
93+
94+
------
95+
### Using 'ccomment'
96+
97+
Example using `#!/usr/bin/env bash
98+
99+
./vhc <<< "vhc:ccomment;Example using 'ccomment'."`.
100+
```
101+
/*
102+
* Example using 'ccomment'.
103+
*/
104+
```
105+
106+
107+
108+
------
109+
### Using 'lcomment'
110+
111+
Example using `#!/usr/bin/env bash
112+
113+
./vhc <<< "vhc:lcomment;Example using 'lcomment'."`.
114+
```
115+
//
116+
// Example using 'lcomment'.
117+
//
118+
```
119+
120+
121+
122+
------
123+
### Using 'box'
124+
125+
Example using `#!/usr/bin/env bash
126+
127+
./vhc <<< "vhc:box;Example using 'box'."`.
128+
```
129+
+----------------------+
130+
| Example using 'box'. |
131+
+----------------------+
132+
```
133+
134+
135+
136+
------
137+
### Using 'star'
138+
139+
Example using `#!/usr/bin/env bash
140+
141+
./vhc <<< "vhc:star;Example using 'star'."`.
142+
```
143+
*************************
144+
* Example using 'star'. *
145+
*************************
146+
```
147+
148+
149+
150+
------
151+
### Using 'stars'
152+
153+
Example using `#!/usr/bin/env bash
154+
155+
./vhc <<< "vhc:stars;Example using 'stars'."`.
156+
```
157+
**************************
158+
* Example using 'stars'. *
159+
**************************
160+
```
161+
162+
163+
164+
------
165+
### Using 'asterisk'
166+
167+
Example using `#!/usr/bin/env bash
168+
169+
./vhc <<< "vhc:asterisk;Example using 'asterisk'."`.
170+
```
171+
*****************************
172+
* Example using 'asterisk'. *
173+
*****************************
174+
```
175+
176+
177+
178+
------
179+
### Using 'ernjs'
180+
181+
Example using `#!/usr/bin/env bash
182+
183+
./vhc <<< "vhc:ernjs;Example using 'ernjs'."`.
184+
```
185+
################################
186+
#### Example using 'ernjs'. ####
187+
################################
188+
```
189+
190+
191+
192+
------
193+
### Using 'ernando'
194+
195+
Example using `#!/usr/bin/env bash
196+
197+
./vhc <<< "vhc:ernando;Example using 'ernando'."`.
198+
```
199+
##################################
200+
#### Example using 'ernando'. ####
201+
##################################
202+
```
203+
204+
205+

Makefile

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#
2+
# λ::Makefile
3+
#
4+
# For further information see `README.md`.
5+
6+
PREFIX?= /bin
7+
TARGET?= ~/.local
8+
SOURCE?= vhc
9+
NULL ?= /dev/null
10+
VIMRC = ~/.vimrc
11+
12+
INSTALL= $(TARGET)$(PREFIX)
13+
VIMCONF= echo 'map <F2> :!vhc' >> $(VIMRC)
14+
15+
ifneq (,$(DESTDIR))
16+
TARGET =$(DESTDIR)
17+
endif
18+
19+
20+
CMD = "\\e[1m%-10s\\e[0m%s\n"
21+
STR = "\\e[0;2;3m%s\\e[0m\n"
22+
HLP = sed -E 's/(`.*`)/\\e[1m\1\\e[0m/'
23+
24+
25+
DEFAULT: help
26+
27+
28+
29+
backup:
30+
@\
31+
cp $(VIMRC) $(VIMRC)_$(shell date +'%Y%m%d%H%M%S')
32+
33+
34+
#
35+
install: backup # Installs application.
36+
@\
37+
mkdir -p $(INSTALL) 2>$(NULL) ; \
38+
install -D $(SOURCE) $(INSTALL)/$(SOURCE) ; \
39+
chmod +x $(INSTALL)/$(SOURCE) ; \
40+
echo Installed into '$(INSTALL)/$(SOURCE)'
41+
42+
@\
43+
LINE=$$(cat $(VIMRC)"" | grep -n "$(SOURCE)"\
44+
| awk -F':' '''{ print($$1); }'); (( sed -i \
45+
"$${LINE},1 s/^[\"| ]*//g" $(VIMRC)))
46+
47+
@\
48+
VIM=$$(cat $(VIMRC)"" | grep "$(SOURCE)") ; \
49+
[ -e $(INSTALL)/$(SOURCE) -a -z "$${VIM}" ] \
50+
&& ((echo 'Configuring VIM'; $(VIMCONF) )) \
51+
|| ((echo "VIM configured with '$${VIM}'"))
52+
53+
54+
55+
uninstall: backup # Uninstalls application.
56+
@\
57+
rm -Rf $(INSTALL)/$(SOURCE); \
58+
echo "'$(INSTALL)/$(SOURCE)' removed."
59+
60+
@\
61+
LINE=$$(cat $(VIMRC) | grep -n "$(SOURCE)" | awk -F':' '{print($$1)}'); \
62+
sed -i "$${LINE},1 s/^/\" /" $(VIMRC)
63+
64+
65+
#
66+
help: # Shows this help.
67+
@\
68+
echo """"""""""""""""""""""""""" \
69+
$$(awk 'BEGIN { FS=":.*?#" } \
70+
/^(\w+:.*|)#/ { \
71+
gsub("^( : |)#( |)", """""""" ); \
72+
LEN=length($$2); COND=(LEN < 1); \
73+
FORMAT=(COND ? $(STR) : $(CMD)); \
74+
printf(FORMAT, $$1, """"""$$2 ); \
75+
}' $(MAKEFILE_LIST) | ($(HLP)))"
76+
77+
78+
#
79+
samples: # Build tests and EXAMPLES.md using possible style options.
80+
@\
81+
mkdir -p tests; \
82+
NUM(){ cat vhc | grep -n "$${1}OPTIONS" | awk -F':' '{print($$1)}'; }; \
83+
INI=$$(NUM "# "); \
84+
END=$$(NUM "#/"); \
85+
MAX=$$(cat vhc | wc -l); \
86+
GET=$$((MAX - INI - 1)); \
87+
LEN=$$((END - INI - 3)); \
88+
TARGET=EXAMPLES.md \
89+
OPTIONS=$$(cat vhc \
90+
| tail -n"$${GET}" \
91+
| head -n"$${LEN}" \
92+
| sed -E 's/^\s+([a-z0-9\-\|\*]*)\).*$$/\1/; s/\|/ /g; s/\*//g'); \
93+
echo "# VIM Header Composer Examples\n\n" \
94+
"> **Warning:** this file was generated by the execution of \`make samples\`, manual changes possible will be overwritten.\n\n" \
95+
"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" \
96+
> $$TARGET; \
97+
for opt in $$OPTIONS; \
98+
do TEST=tests/testing_style_$${opt}.sh; \
99+
echo "Creating test \e[1m$${opt}\e[0m.."; \
100+
echo "------\n### Using '$${opt}'\n" >> $$TARGET; \
101+
echo "#!/usr/bin/env bash\n\n""./vhc <<< \"vhc:"$${opt}";Example using '$${opt}'.\"" > $${TEST}; \
102+
echo "Example using \`$$(cat $${TEST})\`.\n\`\`\`" >> $$TARGET; \
103+
echo "vhc:$${opt};Example using '$${opt}'." | ./vhc > $${TEST}.result;\
104+
echo "$$(cat $${TEST}.result)\n\`\`\`\n\n\n" >> $$TARGET; \
105+
done
106+
107+
108+
#
109+
.PHONY: tests
110+
tests: # Execute tests.
111+
@\
112+
gMD5(){ cat $$1 | md5sum | awk '{print($$1)}'; };\
113+
for each in ./tests/*.sh; \
114+
do bash "$${each}" >.test ; \
115+
TESTS=$$(echo $${each} | sed -E 's/_/ /g; s/\.sh$$//g; s/^.*\///'); \
116+
printf "%*s%s\r%s" 5 "" "$${TESTS}"; \
117+
VALID=$$(gMD5 ".test"); \
118+
CHECK=$$(gMD5 $${each}.result); \
119+
VALUE="\e[31mFail\e[0m"; \
120+
[ "$${VALID}" = "$${CHECK}" ] \
121+
&& VALUE="\e[32mDone\e[0m" \
122+
|| FAIL=true; \
123+
echo "$${VALUE}"; \
124+
done; \
125+
rm -Rf .test; \
126+
[ -z $${FAIL} ] || exit 1
127+
128+
129+
130+
clear: # Clear.
131+
@\
132+
rm -Rf tests .test
133+
134+
#
135+
%:
136+
@:

0 commit comments

Comments
 (0)