* updated pyxdg (0.19 -> 0.28)
[t2sde.git] / t2
blobbe6f3b0c56856fb66c82440b00f76f54c72cba03
1 #!/usr/bin/env bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: t2
4 # Copyright (C) 2023 - 2024 The T2 SDE Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 top=$(readlink -f $0)
14 [ "$top" ] && cd ${top%/*}
16 declare -A commands
18 commands["bootstrap"]="bootstrap vital deps on homebrew systems"
19 commands["config"]="creates a target configuration profile"
20 commands["install"]="installs a package and its dependencies"
21 commands["uninstall"]="uninstalls a package from the system"
22 commands["download"]="downloads assets of a package"
23 commands["build"]="builds a package from source"
24 commands["build-target"]="builds a whole target sandbox"
25 commands["clean"]="clean-up build artifacts"
26 commands["create"]="create a package from external URLs"
27 commands["create-iso"]="create an ISO after a target build"
28 commands["list-errors"]="list build target errors"
29 commands["commit"]="commit changes to the T2 source tree"
30 commands["find"]="find package based on meta data"
31 commands["update"]="update a package meta-data version"
32 commands["upgrade"]="upgrade the system install packages"
33 commands["up|pull"]="update / pull t2 source tree changes"
35 usage() {
36 cat << EOT
37 Usage: t2 command <options>
38 Commands:
39 EOT
41 for i in "${!commands[@]}"; do
42 local desc=${commands[$i]}
43 local n=$((${#i} + 2))
44 local t="\t\t"
45 [ $n -gt 7 ] && t="\t"
46 echo -e " $i$t$desc"
47 done | sort
49 cat << EOT
50 Options:
51 -v, --verbose verbose operation
52 -c, --cfg config name
53 EOT
54 exit 1
57 # convert modern --* args to backward-compat single-dash -*
58 # and save the first non option as cmd
59 cmd=
60 declare -a args
61 for a; do
62 a=(${a/--/-})
63 [[ -z "$cmd" && "$a" = [^-]* && ( ${#args[*]} -eq 0 || ${args[-1]} != "-cfg" ) ]] && cmd="$a" && continue
64 args+=($a)
65 done
67 case "$cmd" in
68 config) exec scripts/Config "${args[@]}" ;;
69 bootstrap) exec scripts/Bootstrap "${args[@]}" ;;
70 build) exec scripts/Build-Pkg "${args[@]}" ;;
71 build-target) exec scripts/Build-Target "${args[@]}" ;;
72 clean) exec scripts/Cleanup "${args[@]}" ;;
73 create) exec scripts/Create-Pkg "${args[@]}" ;;
74 create-iso) exec scripts/Create-ISO "${args[@]}" ;;
75 list-errors) exec scripts/Create-ErrList "${args[@]}" ;;
76 commit|ci) exec scripts/Commit "${args[@]}" ;;
77 download|dl) exec scripts/Download "${args[@]}" ;;
78 find) exec scripts/Find-Pkg "${args[@]}" ;;
79 install|inst) exec scripts/Emerge-Pkg "${args[@]}" ;;
80 update) exec scripts/Update-Pkg "${args[@]}" ;;
81 upgrade) exec scripts/Emerge-Pkg -system "${args[@]}" ;;
82 uninstall) exec mine -r "${args[@]}" ;;
83 up|pull) if [ -e .git ]; then exec git pull; else exec svn up; fi ;;
84 *) usage ;;
85 esac