-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_pont
executable file
·88 lines (79 loc) · 5.59 KB
/
_pont
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
#compdef _pont pont
DOTFILES_HOME=${DOTFILES_HOME:-~/.config/dotfiles}
function __get_presets {
find ${PONT_PRESETS_HOME:-$DOTFILES_HOME/presets/*} -regex '.*.preset' \
-maxdepth 1 -mindepth 1 |
sed -e 's|.*/||' -e 's/.preset//' -e 's/^/+/' -e 's/$/ /'
}
function __get_tags {
find ${PONT_MODULES_HOME:-$DOTFILES_HOME/modules/*} \
-maxdepth 1 -mindepth 1 -name '.tags' \
-exec cat {} + | grep "^[^#;]" |
sort | uniq | sed -e 's/^/:/' -e 's/$/ /'
}
function _pont_modules {
_path_files -S " " -r " " -/ -W ${PONT_MODULES_HOME:-$DOTFILES_HOME/modules}
}
function _pont_presets {
local presets=("${(@f)$(__get_presets)}")
_multi_parts " " 'presets'
}
function _pont_tags {
local tags=("${(@f)$(__get_tags)}")
_multi_parts " " 'tags'
}
function _pont_all {
_pont_modules
_pont_presets
_pont_tags
}
function _pont {
_arguments -S -C \
'(-h --help)'{-h,--help}'[Print information on usage and flags then exit]' \
'(-V --version)'{-V,--version}'[Print script version then exit]' \
'(-l --log --log-level)'{-l,--log,--log-level}'[set log level, possible values are:
0, trace, TRACE
1, info, INFO
2, warning, WARNING, success, SUCCESS
3, error, ERROR
4, none, NONE
each option in a line mean the same thing]'\
'(-v --verbose)'{-v,--verbose}'[log level 0 (trace)]' \
'(-q --quiet)'{-q,--quiet}'[log level 3 (error)]' \
'(-I --list-installed)'{-I,--list-installed}'[List all installed modules then exit]' \
'(-A --list-modules)'{-A,--list-modules}'[List all modules then exit]' \
'(-D --list-deprecated)'{-D,--list-deprecated}'[List all deprecated modules then exit]' \
'(-P --list-presets)'{-P,--list-presets}'[List all presets then exit]' \
'(-T --list-tags)'{-t,--list-tags}'[List all tags then exit]' \
'(-E --list-environment)'{-E,--list-environment}'[List the config environment then exit]' \
'(-L --list-install)'{-L,--list-install}'[List the resolved final module list then exit]' \
'(-Q --list-queue)'{-Q,--list-queue}'[List the execution queue then exit]' \
'(-O --list-outdated)'{-O,--list-outdated}'[List all outdated (installed but has hash mismatch) modules then exit]' \
'(-C --toggle-clean-symlinks)'{-C,--toggle-clean-symlinks}'[Removes broken symlinks in the target directory. (By default it turns on the feautre, but if it was turned on by the environment it turns it off.)]' \
'(-X --toggle-fix-permissions)'{-X,--toggle-fix-permissions}'[Adds user execute permissions to all module scripts before running them.]' \
'(-p --pull-dotfiles)'{-p,--pull-dotfiles}'[Perform git pull on the dotfiles home folder]' \
'(-u --update)'{-u,--update}'[Run all scrips starting with u in the selected modules.]' \
'(-x --execute --install)'{-x,--execute,--install}'[Run init scripts, stow configs, then run scripts starting with a number and the Makefile in all the selected modules.]' \
'(-r --remove)'{-r,--remove}'[Unstows every stow package in the selected modules. If this flag is added twice it will also run all scrips starting with r in the selected modules.]' \
'(-n --expand-none)'{-n,--expand-none}'[Expands only the abstract entries in the direct selection. No dependencies are resolved]' \
'(-e --expand-selected)'{-e,--expand-seleted}'[Expands the original selection (the argument list) down to its dependencies recursively. Use this for regular installations.]' \
'(-a --expand-all)'{-a,--expand-all}'[Expands every module regardless of the current selection.]' \
'(-i --expand-installed)'{-i,--expand-installed}'[Expands every installed module regardless of the current selection. Useful for batch running update and backup scripts]' \
'(-o --expand-outdated)'{-o,--expand-outdated}'[Expands every installed module regardless of the current selection thats saved hash is no longer matching a freshly calculated one. Useful for batch refreshing modules after modifying them]' \
'(-d --dry)'{-d,--dry}'[Disables modifications. No stowing, no script execution. Useful for testing flag combinations.]' \
'(-w --wet)'{-w,--wet}'[Enabled modifications. Stowing, Script execution. On by default.]' \
'(-b --skip-base)'{-b,--skip-base}'[Skip the base modules when expanding selection (Only useful before the -e flag).]' \
'(-f --force)'{-f,--force}'[Ignores hashfiles. To avoid accidentally installing large dependency trees, this automatically turns on --expand-none. Expansion can be changed after.]' \
'(-c --config)'{-c,--config}'[Instead of the selection in the argument list, select entries in a TUI with whiptail.]' \
'--root[Enables root privileged script execution. On by default.]' \
'(-R --skip-root)'{-R,--skip-root}'[Disables root privileged script execution.]' \
'(-s --scripts)'{-s,--scripts}'[Enables script execution. On by default.]' \
'(-S --skip-scripts)'{-S,--skip-scripts}'[Disables script execution. Its like dry execution but with stowing enabled.]' \
'(-m --make)'{-m,--make}'[Enables Makefile execution. On by default.]' \
'(-M --skip-make)'{-M,--skip-make}'[Disables Makefile execution.]' \
'(-t --target)'{-t,--target}'[Its value will specify PONT_TARGET for this execution.]' \
'(--scaffold --cpt)'{--scaffold,--cpt}'[Instead of executing modules, the selection now will used to scaffold modules based on a template folder at PONT_TEMPLATE_HOME]' \
'(-y --yank)'{-y,--yank}'[will yank the selection (with none expansion by default) to the target folder. Useful for copying modules along with their dependencies. (Used presets are also copied!)]' \
'(-Y --yank-expanded)'{-y,--yank}'[will yank the expanded selection (same as -ey) to the target folder.]' \
"*:: :{ _pont_all }"
}