-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathz-run.txt
136 lines (113 loc) · 4.48 KB
/
z-run.txt
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
--------------------------------------------------------------------------------
=== How to execute scriptlets? ===
Basic commands to select and execute scriptlets:
>> z-run ## show main-menu, select, execute
>> z-run ':: menu' ## show sub-menu, select, execute
>> z-run ':: scriptlet' argument ... ## just execute
Alternative commands to select and execute scriptlets:
>> z-run select-execute ## (as above)
>> z-run select-execute ':: menu' ## (as above)
>> z-run execute ':: scriptlet' argument ... ## (as above)
>> z-run execute-ssh user@node ':: scriptlet' argument ...
Advanced commands to interact with scriptlets:
>> z-run list ## print labels
>> z-run select-label ## show main-menu, select, print label
>> z-run select-label ':: menu' ## show sub-menu, select, print label
>> z-run select-body ## show main-menu, select, print body
>> z-run select-body ':: menu' ## show sub-menu, select, print body
>> z-run export-body ':: scriptlet' ## just print body
Advanced commands to interact with the library:
>> z-run export-library-json ## pipe through `jq` for processing
Useful commands:
>> z-run --shell ## starts a custom `bash` shell with a custom rc;
>> source <( z-run --export=shell-functions ) ## exports only `_`;
>> source <( z-run --export=shell-rc-only ) ## exports custom rc witout `_`;
>> source <( z-run --export=shell-rc ) ## exports custom rc with `_`;
>> _ ## runs `z-run` inside the custom shell, with history;
Low-level execution modes:
>> z-run --exec ./path/to/project/scripts/z-run
>> z-run --exec ./path/to/project/scripts/z-run ':: scriptlet' argument ...
>> z-run --workspace=./path/to/project ...
## ^^ use the given path instead of the current folder
>> z-run --untainted ...
## ^^ use another library from within a scriptlet
Low-level SSH mode:
>> z-run --ssh \
--ssh-target=user@node \
--ssh-workspace=/mnt/something \
--ssh-export=NAME=value \
--ssh-path=/opt/something/bin \
--ssh-terminal=dumb \
':: scriptlet' argument ...
Other utilities:
>> z-run --input --help
>> z-run --select --help
>> z-run --fzf --help
--------------------------------------------------------------------------------
=== How to create scriptlets? ===
Place your scriptlets in a source file named like:
* `z-run`, `_z-run`, `.z-run`;
* `zrun`, `_zrun`, `.zrun`;
* another source file included with `&&` in one of the above;
Place your source files in a folder named like:
* `z-run`, `zrun`, `scriptlets`, `scripts`, `bin`;
* perhaps prefix the folder with `_` or `.`;
* perhaps hide them in the `.git`, `.hg`, `.svn` folders;
* else just put them in `${HOME}`;
--------------------------------------------------------------------------------
=== How to write scriptlets? ===
:: hello world :: echo "hello world"
::// *
::// helo world / ...
<< hello world / in Bash
echo 'hello world!'
!!
<< hello world / in Python
#! <python3>
print("hello world!")
!!
##{{
* obviously this section is a comment;
* `::// *` defines a sub menu that
doesn't hide scriptlets from the main menu;
* `::// hello world / ...` defines a sub menu that
does hide scriptlets from the main menu;
* prefix scriptlets with `##` to comment them;
* prefix scriptlets with `--` to
hide them from all menus;
* prefix scriptlets with `++` to
forcibly show them in the main menu;
##}}
&&== path ./tools/bin
&&== path /opt/local/bin
&&== env NAME value
&&== env-fallback NAME default
&&== env-exclude NAME_NOT_NEEDED
&&== env-path FOLDER_ABSOLUTE_PATH ./.outputs
&&== env-path-append CUSTOM_PATH ./tools/bin
&&== env-path-append CUSTOM_PATH /opt/local/bin
&& _/include-file-relative-to-this-source
&& ./scripts/include-file-relative-to-the-workspace
&&?? ./scripts/.local-scriptlets-that-might-not-exist
<<== generate scriptlets
for _environment in production staging development ; do
cat << EOS
<< git / push / ${_environment}
git push github
echo '[ii] deploying to ${_environment}' >&2
git push server/${_environment} HEAD:master
!!
EOS
done
!!
--------------------------------------------------------------------------------
=== How to get more information?
>> z-run --version
>> z-run --help
>> z-run --manual
>> z-run --manual-man
>> z-run --manual-html
>> z-run --readme
>> z-run --readme-html
>> z-run --sbom
>> z-run --sbom-json