#!/usr/bin/perl

use strict;
use Cwd;

open(my $file, '<', 'github_plugins') or die;

if(($ARGV[0]||'') eq 'checkout')
{
  for my $plugin (<$file>)
  {
    chomp($plugin);
    system('git','clone',"https://github.com/JOSM/$plugin");
  }
}
elsif(($ARGV[0]||'') eq 'status')
{
  my $dir = cwd();
  for my $plugin (<$file>)
  {
    print($plugin);
    chomp($plugin);
    chdir($plugin);
    system('git','status',$plugin);
    chdir($dir);
  }
}
else
{
  my $dir = cwd();
  for my $plugin (<$file>)
  {
    print($plugin);
    chomp($plugin);
    chdir($plugin);
    system('git','pull');
    chdir($dir);
  }
}
close($file);