~cadence/bibliogram-updater

ref: 86226e79f9ccd9ec3996220c3c28e1d55b4f8ee6 bibliogram-updater/utils/helpers.fish -rw-r--r-- 652 bytes
86226e79 — Cadence Ember Update most GitHub links 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env fish

# Write the value of variables into a file, using the names of the variables
# as the keys.
# argv[1]: the path to the template.
# argv[...]: the variable names.
# text: the new contents
function write_config
	set -l file_path $argv[1]
	set -l scripts
	for var in $argv[2..-1]
		set -l name (string split ',' $var)[1]
		set -l surround (string split ',' $var)[2]
		set -a scripts "s!\$$name!$surround$$name$surround!"
	end
	sed -e (string join ';' $scripts) $file_path
end

# Attempts to update.
# exit code: 0 if updated, 1 if no updates available
function do_update
	env LANG=C git pull | grep -v 'Already up[ -]to[ -]date.'
end