Skip to content

Instantly share code, notes, and snippets.

@lolgear
Created June 10, 2013 16:07
Show Gist options
  • Save lolgear/5749976 to your computer and use it in GitHub Desktop.
Save lolgear/5749976 to your computer and use it in GitHub Desktop.
This script clear data, which were placed in directory .../DerivedData - directory of compiled Xcode projects
#!/usr/bin/perl
my $pathToCacheDirectory = qq(~/Library/Developer/Xcode/DerivedData/);
sub TaskToDo{
my ($refToArgv)=@_;
die "can't work with too much parameters" unless(scalar(@$refToArgv)==1);
my $what = shift @$refToArgv;
my $time = 30; #wait 30 seconds in each iteration
my $workRef = sub{
print "i will delete: ";
print qx(ls $pathToCacheDirectory);
qx(rm -rf $pathToCacheDirectory);
};
#view help
if ($what eq 'help'){
print qx(perldoc -t $0);
}
#list directory
if ($what eq 'watch'){
print qx(ls $pathToCacheDirectory);
}
#kill files instantly
if ($what eq 'now'){
print 'kill now'.qq(\n);
$workRef->();
print 'see result'.qq(\n);
print qx(ls $pathToCacheDirectory);
}
#switch on watcher
if ($what eq 'work'){
for(;;){
#in INF loop
for my $s(0..4){
#print "this is <<$_>>\n";
print "time remaining: ".(5-$s)*$time." sec \n";
sleep($time);
}
$workRef->();
sleep(10);
}
}
}
TaskToDo(\@ARGV);
__END__
=head1 DESCRIPTION
This script clear directory with cache from Xcode
-- 'help' will show this log
-- 'work' will run script as observer and killer
-- 'watch' will show info about directory with cache
-- 'now' will kill all instantly
Example: perl scriptName.pl help
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment