Skip to content

Commit b610c23

Browse files
committed
see CHANGELOG
1 parent c95fddd commit b610c23

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/*

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
March 19, 2024:
2+
- Added a versioning scheme, first release
3+
- major.minor.revision -> 1.0.0
4+
- major: +1 when a new feature is added
5+
- minor: +1 when fixing something
6+
- revision: +1 for anything else that doesn't affect
7+
the program that much
8+
- Commented the code a bit better
9+
- Updated 'help'
10+
- Removed a redundancy on the code, see diff for 'delete'
11+
- Created this changelog thing

fpkg

100644100755
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
FPKGDIR="/usr/local/fpkg/" # where all packages are located at
44
EDIOR="vim" # change this to your favorite editor
55

6+
VERSION="1.0.0" # not sure why i want a variable for that honestly
7+
68
error () {
79
popd > /dev/null
810
stty echo
911
exit 1
1012
}
1113

1214
write_check () {
15+
# get return code to see if we can write to any of the files
1316
touch $FPKGDIR > /dev/null 2>&1
1417
ret=$((ret + $?))
1518
touch $FPKGDIR/pkg.list > /dev/null 2>&1
1619
ret=$((ret + $?))
1720
touch $FPKGDIR/ii > /dev/null 2>&1
1821
ret=$((ret + $?))
1922

20-
if [[ $ret > 0 ]]; then
23+
if [[ $ret > 0 ]]; then # if any of the touch's fail
2124
echo "ERROR: you cannot write to $FPKGDIR! Please run as root"
2225
error
2326
fi
2427
}
2528

26-
# hide the keystrokes, save current directory to go to
27-
# the fpkg one
29+
# hide keystrokes, save current directory to go to $FPKGDIR
2830
stty -echo
2931
pushd . > /dev/null
3032
cd $FPKGDIR
@@ -33,7 +35,7 @@ if [[ $? != 0 ]]; then
3335
echo "ERROR: $FPKGDIR does not exist! Create it now? [Y/n]"
3436
read choice
3537

36-
if [[ choice != "n" ]]; then
38+
if [[ choice != "n" ]]; then # so that the default is "yes"
3739
mkdir -v $FPKGDIR
3840
fi
3941

@@ -43,7 +45,7 @@ fi
4345
case $1 in
4446
# refresh every package using git pull
4547
"update" | "u")
46-
entries=$(cat pkg.list | wc -l)
48+
entries=$(cat pkg.list | wc -l) # how many packages do we have?
4749

4850
for ((i = 1; i <= $entries; i++)); do
4951
pkg_dir=$(head -n $i pkg.list | tail -1)
@@ -87,7 +89,7 @@ case $1 in
8789
"list" | "l")
8890
cat pkg.list
8991
echo ""
90-
echo "Total: $(cat pkg.list | wc -l)"
92+
echo "Total: $(cat pkg.list | wc -l)" # get the number of installed packages as well
9193
;;
9294

9395
# adding an entry to the list?
@@ -111,19 +113,16 @@ case $1 in
111113
stty echo
112114
echo "Removing:"
113115
read pkg_name
114-
entry=$(grep -w "^$pkg_name" pkg.list -n | awk -F: '{ print $1 }')
116+
entry=$(grep -w "^$pkg_name" pkg.list -n | awk -F: '{ print $1 }') # FIXME: is there a better way of doing this?
115117
sed -i "$entry"d pkg.list
116118
rm ii/$pkg_name.ii
117119
echo "$pkg_name removed, would you like to remove its files as well? [y/N]"
118120
read file_removal
119121

120-
if [[ $file_removal = 'y' ]]; then
122+
if [[ $file_removal = 'y' ]]; then # same thing but with "no"
121123
echo "Package directory (relative to /usr/local/fpkg/):"
122124
read dir
123125
rm -rf $dir
124-
else
125-
popd > /dev/null
126-
stty echo
127126
fi
128127
;;
129128

@@ -152,18 +151,26 @@ case $1 in
152151
fi
153152
;;
154153

155-
# didn't even input a valid option?
154+
# requested the version?
155+
"version" | "v")
156+
echo "fpkg version $VERSION"
157+
echo "2024 ruby R53 (https://github.com/ruby-R53)"
158+
;;
159+
160+
# didn't even input a valid action or wants to know
161+
# them?
156162
"help" | *)
157163
echo "Usage: fpkg [action] [package]"
158164
echo "Actions:"
159-
echo "help | h - shows this help message"
160-
echo "update | u - git pull every package listed in pkg.list"
161-
echo "install | i <pkg> - install <pkg> using instruction file"
162-
echo "list | l - list all registered packages"
163-
echo "add | a - add a package to the list"
164-
echo "delete | d - remove a package from the list"
165-
echo "message [-d] <pkg> - get comment from last git commit of <pkg>. Takes an"
166-
echo " optional -d for getting the diff"
165+
echo "help | h - shows this help message"
166+
echo "update | u - git pull every package listed in pkg.list"
167+
echo "install | i <pkg> - install <pkg> using instruction file"
168+
echo "list | l - list registered packages"
169+
echo "add | a - register a package"
170+
echo "delete | d - remove a package"
171+
echo "message | m [-d] <pkg> - get comment from last git commit of <pkg>. Takes an"
172+
echo " optional -d for getting the diff"
173+
echo "version | v - get fpkg's version"
167174

168175
if [[ $1 != "help" ]]; then
169176
error

0 commit comments

Comments
 (0)