109 lines
2.2 KiB
Bash
Executable File
109 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
#
|
|
# This file is part of the distrobox project:
|
|
# https://github.com/89luca89/distrobox
|
|
#
|
|
# Copyright (C) 2021 distrobox contributors
|
|
#
|
|
# distrobox is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License version 3
|
|
# as published by the Free Software Foundation.
|
|
#
|
|
# distrobox is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# POSIX
|
|
set -o errexit
|
|
set -o nounset
|
|
|
|
version="1.8.2.2"
|
|
|
|
# show_help will print usage to stdout.
|
|
# Arguments:
|
|
# None
|
|
# Expected global variables:
|
|
# version: distrobox version
|
|
# Expected env variables:
|
|
# None
|
|
# Outputs:
|
|
# print usage with examples.
|
|
show_help()
|
|
{
|
|
cat << EOF
|
|
distrobox version: ${version}
|
|
|
|
Choose one of the available commands:
|
|
assemble
|
|
create
|
|
enter
|
|
list | ls
|
|
rm
|
|
stop
|
|
upgrade
|
|
ephemeral
|
|
generate-entry
|
|
version
|
|
help
|
|
EOF
|
|
}
|
|
|
|
if [ $# -eq 0 ]; then
|
|
show_help
|
|
exit
|
|
fi
|
|
|
|
distrobox_path="$(dirname "${0}")"
|
|
distrobox_command="${1}"
|
|
shift
|
|
|
|
# Simple wrapper to the distrobox utilities.
|
|
# We just detect the 1st argument and launch the matching distrobox utility.
|
|
case "${distrobox_command}" in
|
|
assemble)
|
|
"${distrobox_path}"/distrobox-assemble "$@"
|
|
;;
|
|
create)
|
|
"${distrobox_path}"/distrobox-create "$@"
|
|
;;
|
|
enter)
|
|
"${distrobox_path}"/distrobox-enter "$@"
|
|
;;
|
|
ls | list)
|
|
"${distrobox_path}"/distrobox-list "$@"
|
|
;;
|
|
stop)
|
|
"${distrobox_path}"/distrobox-stop "$@"
|
|
;;
|
|
rm)
|
|
"${distrobox_path}"/distrobox-rm "$@"
|
|
;;
|
|
upgrade)
|
|
"${distrobox_path}"/distrobox-upgrade "$@"
|
|
;;
|
|
generate-entry)
|
|
"${distrobox_path}"/distrobox-generate-entry "$@"
|
|
;;
|
|
ephemeral)
|
|
"${distrobox_path}"/distrobox-ephemeral "$@"
|
|
;;
|
|
-V | --version | version)
|
|
printf "distrobox: %s\n" "${version}"
|
|
exit 0
|
|
;;
|
|
help | --help | -h)
|
|
show_help
|
|
exit 0
|
|
;;
|
|
*) # Default case: If no more options then break out of the loop.
|
|
printf >&2 "Error: invalid command\n"
|
|
show_help
|
|
exit 1
|
|
;;
|
|
esac
|