Changeset 1654
- Timestamp:
- 09/02/06 22:04:43
- Files:
-
- trunk/plagger (modified) (previous)
- trunk/plagger/tools/plugin-start.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/tools/plugin-start.pl
r1423 r1654 3 3 use warnings; 4 4 5 use Config; 5 6 use FindBin; 6 7 use ExtUtils::MakeMaker; … … 39 40 my $template = YAML::Load(join '', <DATA>); 40 41 my $vars = { module => $module, plugin => $plugin, path => $path, author => $author }; 41 write_file("lib/Plagger/Plugin/$path.pm", $template->{plugin}, $vars); 42 write_file("deps/$plugin.yaml", $template->{deps}, $vars); 43 write_file("t/plugins/$plugin/base.t", $template->{test}, $vars); 42 43 my @files; 44 push @files, write_file("lib/Plagger/Plugin/$path.pm", $template->{plugin}, $vars); 45 push @files, write_file("deps/$plugin.yaml", $template->{deps}, $vars); 46 push @files, write_file("t/plugins/$plugin/base.t", $template->{test}, $vars); 47 48 if (my $vcs = version_control()) { 49 my $ans = prompt("$vcs add newly created files? [Yn]", 'y'); 50 if ($ans =~ /[Yy]/) { 51 system($vcs, 'add', @files); 52 } 53 } 44 54 } 45 55 … … 65 75 print $out $content; 66 76 close $out; 77 78 return $path; 79 } 80 81 sub version_control { 82 return 'svk' if check_command('svk', 'svk info', qr/Checkout Path/); 83 return 'svn' if -e ".svn/entries"; 84 return; 85 } 86 87 sub check_command { 88 my($bin, $command, $re) = @_; 89 return unless grep { -e File::Spec->catfile($_, $bin) } split /$Config::Config{path_sep}/, $ENV{PATH}; 90 91 my $res = qx($command); 92 defined $res && $res =~ $re; 67 93 } 68 94
