Commit f9bcecc4 authored by Pierre-Yves Fourmond's avatar Pierre-Yves Fourmond

Fixed Issue #6

command line: Allow remove command to use several software names
parent 28cd89b1
......@@ -40,6 +40,7 @@ Starting from [0.2-dev version] (https://framagit.org/grumpyf0x48/liar/tree/mast
- Improvements for binaries filtering in symbolic links creation
- Simplified usage with samples only displayed in verbose mode
- Automatic completion of software names and urls for tested softwares (for x86_64 architecture)
- Remove command is now able to remove several softwares at a time
## 2. Installation
......@@ -328,7 +329,11 @@ list command displays installation name, folder, from which archive file the ins
Removing 'sublime3' installed in '/home/debian/Programs/sublime3'
Do you want to remove 'sublime3' installed in '/home/debian/Programs/sublime3' (Y/N) ? Y
When removing a software, a confirmation is asked to the user.
When removing a software, a confirmation is asked to the user unless '-f' option is used.
Moreover, this command can also remove multiple software at once, for example:
$ liar remove sublime3 robo3t
## 4. Documentation
......@@ -379,7 +384,7 @@ To get help of `liar` usage, simply enter:
help Display this help.
install NAME FILE_PATH Install a software packaged in the archive FILE_PATH into the folder DESTINATION under the name NAME.
list List installed software.
remove NAME Remove the software named NAME.
remove NAMES... Remove the software(s) named NAMES.
version Print the version of liar.
With `-v` option, `liar` help output also includes sample commands:
......
......@@ -46,7 +46,7 @@ Usage: $LIAR [OPTIONS...] COMMAND [PARAMETERS...]
help Display this help.
install NAME FILE_PATH Install a software packaged in the archive FILE_PATH into the folder DESTINATION under the name NAME.
list List installed software.
remove NAME Remove the software named NAME.
remove NAMES... Remove the software(s) named NAMES.
version Print the version of $LIAR.
EOF
if [ -n "$VERBOSE" ]; then
......@@ -387,17 +387,18 @@ parse() {
fi
CMD="$1"
shift
case "$CMD" in
install)
NAME="$2"
FILE_PATH="$3"
NAME="$1"
FILE_PATH="$2"
;;
list | help | version)
;;
remove)
NAME="$2"
NAMES="$*"
;;
*) echo "Unsupported command: $1 !" >&2
*) echo "Unsupported command: $CMD !" >&2
return 1
;;
esac
......@@ -438,7 +439,7 @@ parse() {
USER_AGENT_COMMAND="$USER_AGENT $USER_AGENT_OPTS"
fi
# Compute some globals for 'install' and 'remove' commands
# Compute some globals for 'install' command
if [ -n "$NAME" ]; then
INSTALL_FOLDER="$DEST_FOLDER/$NAME"
INSTALL_METADATA="$INSTALL_FOLDER/.liar"
......@@ -590,40 +591,45 @@ liar_list() {
}
liar_remove() {
if [ -z "$NAME" ]; then
echo "NAME is not set !" >&2
if [ -z "$NAMES" ]; then
echo "NAMES is not set !" >&2
return 1
fi
echo "Removing '$NAME' installed in '$INSTALL_FOLDER'"
for NAME in $NAMES; do
INSTALL_FOLDER="$DEST_FOLDER/$NAME"
INSTALL_METADATA="$INSTALL_FOLDER/.liar"
if [ ! -d "$INSTALL_FOLDER" ]; then
echo "'$NAME' does not seem to be installed in '$INSTALL_FOLDER' !" >&2
return 1
fi
echo "Removing '$NAME' installed in '$INSTALL_FOLDER'"
if [ ! -f "$INSTALL_METADATA" ]; then
echo "'$NAME' was not installed by $LIAR !" >&2
return 1
fi
if [ ! -d "$INSTALL_FOLDER" ]; then
echo "'$NAME' does not seem to be installed in '$INSTALL_FOLDER' !" >&2
return 1
fi
if [ -z "$FORCE" ]; then
echo "Do you want to remove '$NAME' installed in '$INSTALL_FOLDER' (Y/N) ?"
read -r answer
if [ "$answer" != "Y" ]; then
echo "Aborting !" >&2
if [ ! -f "$INSTALL_METADATA" ]; then
echo "'$NAME' was not installed by $LIAR !" >&2
return 1
fi
fi
install_links="$INSTALL_FOLDER/.liar_links"
if [ -f "$install_links" ]; then
while read -r link_name; do
rm -f "$link_name"
done < "$install_links"
fi
if [ -z "$FORCE" ]; then
echo "Do you want to remove '$NAME' installed in '$INSTALL_FOLDER' (Y/N) ?"
read -r answer
if [ "$answer" != "Y" ]; then
echo "Aborting !" >&2
continue
fi
fi
rm -fr "$INSTALL_FOLDER"
install_links="$INSTALL_FOLDER/.liar_links"
if [ -f "$install_links" ]; then
while read -r link_name; do
rm -f "$link_name"
done < "$install_links"
fi
rm -fr "$INSTALL_FOLDER"
done
}
liar_main() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment