Skip to content

Commit 3e1ac55

Browse files
Add help messages
1 parent 6ce50e1 commit 3e1ac55

File tree

2 files changed

+76
-11
lines changed

2 files changed

+76
-11
lines changed

udroid/src/help_udroid.sh

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
#!/bin/bash
22

3+
# (C) 2023 RandomCoderOrg, ubuntu-on-android
4+
# help_udroid.sh: A part of udroid scripts
5+
# To show help messages for different options in udroid scripts
6+
#
7+
8+
# help_login: show help for login
39
help_login() {
4-
# TODO: Add help for login
5-
:
10+
echo "udroid [ login| --login ] [<options>] <suite>:<varient> <cmd>"
11+
echo "login to a suite"
12+
echo
13+
echo "options:"
14+
echo " -h, --help: show this help message and exit"
15+
echo " --user: Allows the user to specify the login user for the filesystem."
16+
# echo "-p or --path: Allows the user to set a custom installation path for the filesystem instead of the default directory."
17+
echo " --name: Allows the user to specify a custom name for the filesystem to install"
18+
echo " --bind or -b: Allows the user to specify extra mount points for the filesystem."
19+
echo " --isolated: Creates an isolated environment for the filesystem."
20+
echo " --fix-low-ports: Fixes low ports for the filesystem."
21+
echo " --no-shared-tmp: Disables shared tmp for the filesystem."
22+
echo " --no-link2symlink: Disables link2symlink for the filesystem."
23+
echo " --no-sysvipc: Disables sysvipc for the filesystem."
24+
echo " --no-fake-root-id: Disables fake root id for the filesystem."
25+
# echo "--no-cwd-active-directory | --ncwd (unstable): Disables the current working directory for the active directory for the filesystem."
26+
echo " --no-kill-on-exit: Disables kill on exit for the filesystem."
27+
echo
28+
echo "<cmd>:"
29+
echo " command to run in the filesystem and exit"
630
}
731

32+
# help_root: show help when no option is given or every option is invalid
33+
help_root() {
34+
echo "udroid <option> [<options>] [<suite>]:[<varient>]"
35+
echo
36+
echo "options:"
37+
echo " install, --install [<options>] <suite>:<varient> install a distro"
38+
echo " remove, --remove <suite>:<varient> remove a distro"
39+
echo " list, --list [options] list distros"
40+
echo " login, --login <suite>:<varient> login to a distro"
41+
echo " upgrade, --upgrade upgrade udroid scripts"
42+
echo " help, --help show this help message and exit"
43+
echo " --update-cache update cache from remote"
44+
echo
45+
}
46+
47+
# help_list: show help for list
848
help_list() {
949
echo "udroid [ list| --list ] [options]"
1050
echo "options:"
@@ -14,14 +54,20 @@ help_list() {
1454
echo " --list-installed show only installed distros"
1555
}
1656

57+
# help_upgrade: show help for upgrade
1758
help_install() {
18-
echo "udroid [ install| --install ] <distro>"
59+
echo "udroid [ install| --install ] [<options>] [<suite>]:[<varient>]"
1960
echo "installs udroid distros"
61+
echo "options:"
62+
echo " -h, --help show this help message and exit"
63+
echo " --no-verify-integrity do not verify integrity of filesystem"
64+
echo
2065
echo "example:"
2166
echo " udroid install jammy:raw"
2267
echo " udroid install --install jammy:raw"
2368
}
2469

70+
# help_upgrade: show help for upgrade
2571
help_remove() {
2672
echo "udroid [ remove| --remove ] <distro>"
2773
echo "removes udroid distros"

udroid/src/udroid.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ install() {
146146
no_check_integrity=true
147147
shift
148148
;;
149+
--help | -h)
150+
help_install
151+
exit 0
152+
;;
149153
*)
150154
# [[ -n $_name ]] && {
151155
# ELOG "login() error: name already set to $_name"
@@ -288,6 +292,10 @@ login() {
288292
shift
289293
break
290294
;;
295+
--help | -h)
296+
help_login
297+
exit 0
298+
;;
291299
-p | --path)
292300

293301
# Custom paths are set either to point a new directory instead of default
@@ -690,10 +698,9 @@ parser() {
690698
shasum=$(cat $distro_data | jq -r ".$suite.$varient.${arch}sha")
691699
LOG "shasum=$shasum"
692700
}
693-
701+
## List
702+
# list all the avalible suites varients and their status
694703
list() {
695-
## List
696-
# list all the avalible suites varients and their status
697704

698705
export size=false
699706
export show_installed_only=false
@@ -834,7 +841,19 @@ update_cache() {
834841
# To upgrade tool with git
835842
# by maintaining a local cache
836843
_upgrade() {
837-
local branch=$1
844+
845+
local branch=""
846+
847+
while [ $# -gt 0 ]; do
848+
case $1 in
849+
--branch) branch=$2; shift 2;;
850+
--help) help_upgrade; exit 0;;
851+
*) shift ;;
852+
esac
853+
done
854+
855+
[[ -z $branch ]] && branch="revamp-v2.5"
856+
# [[ -z $branch ]] && branch="main"
838857

839858
# place to store repository
840859
repo_cache="${HOME}/.fs-manager-udroid"
@@ -875,7 +894,7 @@ _upgrade() {
875894
LOG "upgrade(): installing"
876895
bash install.sh
877896

878-
# TODO: look out for commit hashes to see if upgrade is needed
897+
# TODO: look out for commit hashes for better upgrade strategy
879898

880899
}
881900

@@ -930,19 +949,19 @@ trap 'echo "exiting gracefully..."; exit 1' HUP INT TERM
930949
####################
931950

932951
if [ $# -eq 0 ]; then
933-
echo "usage: $0 [install|login|remove]"
952+
help_root
934953
exit 1
935954
fi
936955

937956
while [ $# -gt 0 ]; do
938957
case $1 in
939958
install | --install|-i) shift 1; install $@ ; break ;;
940-
upgrade | --upgrade|-u) shift 1; _upgrade "revamp-v2.5" ; break ;;
959+
upgrade | --upgrade|-u) shift 1; _upgrade $@ ; break ;;
941960
--update-cache) shift 1; update_cache $@ ; break ;;
942961
login | --login|-l) shift 1; login $@; break ;;
943962
remove | --remove | --uninstall ) shift 1 ; remove $@; break;;
944963
reset | --reset | --reinstall ) shift 1 ; _reset $@; break;;
945964
list | --list) shift 1; list $@; break ;;
946-
*) echo "unkown option [$1]"; break ;;
965+
*) echo "unkown option [$1]"; help_root; break ;;
947966
esac
948967
done

0 commit comments

Comments
 (0)