-
Notifications
You must be signed in to change notification settings - Fork 0
/
save-save-mac.fish
executable file
·60 lines (46 loc) · 1.76 KB
/
save-save-mac.fish
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
#!/usr/bin/env fish
# This script will copy the blueprint-storage.dat from the game folder
# and will commit/push it along with the save file (zip). Note that
# we don't copy the game save because it is expected that there is a
# symlink from the game folder to the repo folder so that the save files
# are automatically up to date in the repo folder.
function die
echo -e "$argv" 1>&2
exit 1
end
function ensure_folder_exists
set -l folder $argv[1]
test -d $folder; or die "folder $folder does not exist"
return 0
end
function ensure_file_exists
set -l file $argv[1]
test -f $file; or die "file $file does not exist"
return 0
end
function ensure_link_exists
set -l link $argv[1]
test -L $link; or die "link $link does not exist"
return 0
end
if test (count $argv) -lt 1
die "must specify commit message as first argument"
end
set -l msg "$argv[1]"
set -l library_factorio "/Users/dsicilia/Library/Application Support/factorio"
set -l saves_link "/Users/dsicilia/Library/Application Support/factorio/saves"
set -l factorio_saves "/Users/dsicilia/games/factorio-saves"
set -l blueprint_storage "blueprint-storage.dat"
set -l save_zip "saves/dsicilia.zip"
ensure_folder_exists $library_factorio
ensure_folder_exists $factorio_saves
ensure_link_exists $saves_link
cp "$library_factorio/$blueprint_storage" "$factorio_saves/$blueprint_storage"
or die "failed to copy $library_factorio/$blueprint_storage to $factorio_saves/$blueprint_storage"
cd $factorio_saves; or die "failed to change to directory $factorio_saves"
git status; or die "failed to run git status"
ensure_file_exists $blueprint_storage
ensure_file_exists $save_zip
git add $blueprint_storage $save_zip; or die "failed to git add"
git commit -m "'$msg'"
push