-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc
executable file
·148 lines (124 loc) · 3.04 KB
/
doc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
if [ ! -t 0 ]
then
echo "piping feature is not yet implemented!"
exit
fi
repo=$1
command=$2
parameter=$3
if [ "$repo" == "" ]
then
echo "Invalid repo directory"
exit
fi
dir="$(cd $(dirname $0);pwd)"
if [ ! -f "$dir/src/variables.sh" ]
then
if [ -f "$GKSRC/src/variables.sh" ]
then
dir=$GKSRC
else
echo "Please export source directory"
echo "export GKSRC='/path/to/gitkeep/source'"
echo "add this line to your shell's init file (.bashrc, .zshrc)"
exit 1
fi
fi
# import source files
local_dir="$dir/src"
source "$local_dir/variables.sh"
source "$local_dir/colors.sh"
source "$local_dir/helpers.sh"
source "$local_dir/error.sh"
source "$local_dir/editor.sh"
source "$local_dir/functions.sh"
source "$local_dir/functions.ls.sh"
source "$local_dir/functions.update.sh"
source "$local_dir/functions.precheck.sh"
source "$local_dir/functions.edit.sh"
source "$local_dir/functions.cat.sh"
source "$local_dir/functions.del.sh"
if [ ! -d $repo ]
then
echo $repo does not exist! Please create it before usage
exit
fi
# change directory to repo
cd $repo
# if repository not initialized then notify
if [ "$command" != "init" ] && [ "$command" != "i" ] && [ ! -d ".git" ]
then
color $Red
print "Repository not initialized yet!"
color $Green
print "please run :"
color $Color_Off
print " doc [init|i]"
print
exit
fi
# commands
if [ $# -gt 0 ]
then
if [ "$command" == "init" ] || [ "$command" == "i" ]
then
if [ -d ".git" ]
then
colori $Yellow
echo "Already Initialized"
verify_requirements
else
colori $UGreen
echo "Initializing_repo :"
colori $Red
git init
verify_requirements
fi
elif [ "$command" == "add" ] || [ "$command" == "a" ]
then
add
elif [ "$command" == "list-files" ] || [ "$command" == "ls" ]
then
list_info
elif [ "$command" == "git" ]
then
IFS=' ' read -r -a git_command <<< "$@"
exec "${git_command[@]:1}"
elif [ "$command" == "edit" ] || [ "$command" == "e" ]
then
if [ "$parameter" == "header" ]
then
edit $header_file
updateREADME "Changed header."
elif [ "$parameter" == "footer" ]
then
edit $footer_file
updateREADME "Changed footer."
elif [ "$parameter" == "" ]
then
colori $Red
printi "Invalid file name!\n"
else
# edit file with number
editWithNumber $parameter
fi
elif [ "$command" == "cat" ] || [ "$command" == "c" ]
then
showFileWithNumber $parameter
elif [ "$command" == "del" ] || [ "$command" == "d" ]
then
deleteWithNumber $parameter
elif [ "$command" == "help" ] || [ "$command" == "h" ]
then
error
else
color $Red
echo "Invalid parameters"
error
fi
exit 0
else
error
fi
color $Color_Off