-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplates.go
58 lines (47 loc) · 1.61 KB
/
templates.go
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
package main
const MAIN_TEMPLATE = `
Welcome to SyncEnv!!!
Simple Env Variables Management tool
Supported Actions
Intialise: init
This action adds the current directory to SycnEnv store.
Additionally if you want to migrate local variabales that you have already, use --with-file.
Usage: SyncEnv init, SyncEnv init --with-file <path to local file>
Addtion: --add
This action adds a new variable to the SyncEnv
Usage: SyncEnv --add foo=bar --add baz=gaz
Updation: --update
This action updates an existing variable
Usage: SyncEnv --update foo=gaz --update baz=bar
Peek: --peek
This action lets you have a glance at the stored variables
Usage: SyncEnv --peek
Porting: --port
This actions ports the SyncEnv variables to requested file
Usage: SyncEnv --port <path>, SyncEnv --port
`
const LOAD_TEMPLATE = `Loading: load
This action loads the latest variables to the current shell session
This has to be ran as shell's eval.
If you want to load from local .env file, add --from-file
Additionally --no-debug flag can be paused to prevent message outputs on load action
Usage: SyncEnv load, SyncEnv load --from-file <path>, SyncEnv load --no-debug
`
// Check syncenv_hook, if not found, add it to the PROMPT_COMMAND
const BASH_HOOK = `
syncenv_hook(){
local prev_exit=$?;
eval "$(SyncEnv load --no-debug)";
return $prev_exit;
};
if [[ ";${PROMPT_COMMAND[*]:-};" != *";syncenv_hook;"* ]]; then
PROMPT_COMMAND="syncenv_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
fi
`
// append the syncenv_hook to zsh chpwd_functions
const ZSH_HOOK = `
syncenv_hook(){
eval "$(SyncEnv load --no-debug)"
}
chpwd_functions=("syncenv_hook" "${chpwd_functions[@]}")
`