-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathart
109 lines (91 loc) · 2.13 KB
/
art
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
#!/bin/perl
use File::Spec::Functions;
use File::Basename;
use File::Copy;
use Cwd 'realpath';
use Switch;
#MAIN
if( @ARGV != 1 ) {
print "Whoa there, not the right number of arguments. I was expecting ONE.\n";
exit;
}
switch ($ARGV[0]) {
case "--help" { displayHelp(); }
case "push" { doArtPush(); exit; }
case "pull" { doArtPull(); exit; }
case "sync" { doArtPull(); doArtPush(); exit;}
else { displayHelp(); }
}
#END MAIN
sub displayHelp
{
my $h=<<END;
Usage: art [--push][--pull][--sync]
Use this utility to synchronize art files for project-eva between your computer
and Dropbox. Uses system last modified time to attempt to keep newest copies of files.
push Push your local changes to the art to Dropbox
pull Pull changes from Dropbox to your local copy of the game
sync Shorthand for a pull, then a push
END
print $h;
exit;
}
sub doArtPush
{
# TODO: IMPLEMENT THIS
$DBPATH = getDBDir();
$ASSETSDIR = catdir($DBPATH, "Assets");
print "ERROR: Not implemented yet\n";
}
sub doArtPull
{
$DBPATH = getDBDir();
$ASSETSDIR = catdir($DBPATH, "Assets");
`cp -rv \"$ASSETSDIR\" .`;
print "Art pulled from Dropbox\n";
}
sub touchConf
{
# Check if dropbox has been configured
if( ! -e 'box.conf' ) {
# Create the conf file
`touch box.conf`;
# Check the default directory
if( -d "~/Dropbox/project-eva" ) {
`echo ~/Dropbox/project-eva > box.conf`;
} else {
promptEnterDBFolder();
}
}
}
sub getDBDir
{
touchConf();
open my $CONF, "box.conf" or die "Couldn't find your box.conf file!";
$DBPATH = <$CONF>;
chomp($DBPATH);
$DBPATH = realpath($DBPATH);
if( ! -d $DBPATH ) {
print "I couldn't find your Dropbox folder. Did you edit box.conf?";
exit 1;
}
return $DBPATH
}
sub promptEnterDBFolder
{
print "Before we continue, I need the absolute path\nto your project-eva Dropbox folder.\n";
print "EX: C:\\Users\\Alex\\Dropbox\\project-eva\\\n";
$found = 0;
while($found < 1) {
print "PATH:\t";
$DBPATH = <STDIN>;
chomp($DBPATH);
$DBPATH = realpath($DBPATH);
if( -d $DBPATH ) {
$found += 1;
`echo $DBPATH > box.conf`;
} else {
print "\nSorry, I couldn't find that path. Try again";
}
}
}