forked from 89luca89/distrobox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
distrobox
executable file
·99 lines (91 loc) · 2.08 KB
/
distrobox
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
#!/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
trap '[ "$?" -ne 0 ] && printf "\nAn error occurred\n"' EXIT
version="1.3.2"
# Print usage to stdout.
# Arguments:
# None
# Outputs:
# print usage with examples.
show_help() {
cat << EOF
distrobox version: ${version}
Choose one of the available commands:
create
enter
ephemeral
list
rm
stop
version
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
create)
"${distrobox_path}"/distrobox-create "$@"
;;
enter)
"${distrobox_path}"/distrobox-enter "$@"
;;
list)
"${distrobox_path}"/distrobox-list "$@"
;;
stop)
"${distrobox_path}"/distrobox-stop "$@"
;;
rm)
"${distrobox_path}"/distrobox-rm "$@"
;;
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)
if command -v man > /dev/null; then
man distrobox || show_help
exit 0
fi
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