Skip to content

Commit 6e1e930

Browse files
author
fabiantheblind
committed
added some arguments to TOC dcript
1 parent 5d42b59 commit 6e1e930

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

argument_passing.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
usage="$(basename "$0") [-h] [-s n] -- program to calculate the answer to life, the universe and everything
2+
3+
where:
4+
-h show this help text
5+
-s set the seed value (default: 42)"
6+
7+
seed=42
8+
while getopts ':hs:' option; do
9+
case "$option" in
10+
h) echo "$usage"
11+
exit
12+
;;
13+
s) seed=$OPTARG
14+
;;
15+
:) printf "missing argument for -%s\n" "$OPTARG" >&2
16+
echo "$usage" >&2
17+
exit 1
18+
;;
19+
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
20+
echo "$usage" >&2
21+
exit 1
22+
;;
23+
esac
24+
done

create_toc_of_folder.sh

100644100755
Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,45 @@
55
# TODO:
66
# make a interface to add raw links right now it points to a fixed location
77
# should maybe be a python script
8-
#touch overview.md
8+
9+
usage="$(basename "$0") [-h] [-p path] -- program to create TOC (table of contents) of a folder
10+
11+
where:
12+
-h show this help text
13+
-n number of lines to fetch from files
14+
-p path to github repository for direct links to raw file e.g.
15+
https://raw.github.com/fabiantheblind/auto-typo-adbe-id/master/fabiantheblind/"
16+
17+
path=
18+
numlines=7
19+
while getopts :h:p:n: option
20+
do
21+
case "$option" in
22+
h) echo "$usage"
23+
exit
24+
;;
25+
p) path=$OPTARG
26+
;;
27+
n) numlines=$OPTARG
28+
;;
29+
:) printf "missing argument for -%p\n" "$OPTARG" >&2
30+
echo "$usage" >&2
31+
exit 1
32+
;;
33+
\?) printf "illegal option: -%p\n" "$OPTARG" >&2
34+
echo "$usage" >&2
35+
exit 1
36+
;;
37+
esac
38+
done
39+
if [ $# -eq 0 ]
40+
then
41+
echo "No arguments supplied"
42+
echo "$usage" >&2
43+
exit 1
44+
fi
45+
46+
947
if [ -e "TOC.md" ]; then
1048
echo "\"TOC.md\" already exists. I will remove it"
1149
rm TOC.md
@@ -17,11 +55,12 @@ echo "There are $numfiles .jsx / .txt / .sh files in this directory"
1755
echo "##Autogenerated TOC " >> TOC.md;
1856
for file in *.{jsx,json,txt,sh}; do
1957
if [ -e "$file" ]; then
20-
echo "###[${file}](https://raw.github.com/fabiantheblind/auto-typo-adbe-id/master/fabiantheblind/${file}) " >> TOC.md;
21-
#echo " \n" >> TOC.md;
22-
head -7 "${file}" >> TOC.md;
58+
echo "###[${file}]($path${file}) " >> TOC.md;
2359
#echo " \n" >> TOC.md;
24-
echo " \\n-------------- \\n " >> TOC.md;
60+
head -$numlines "${file}" >> TOC.md;
61+
echo "" >> TOC.md;
62+
echo "-------------- " >> TOC.md;
63+
echo "" >> TOC.md;
2564
fi
2665
done
2766
open TOC.md

removefromhistory.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)