From 28c9853a2cb8b789eaecf76ed18b4230eee45ca4 Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Wed, 1 Jun 2011 03:20:33 -0700 Subject: newrepo: migrating rebuild logic out of Repo.pm and making --enable/disable-ikiwiki work --- pinyadmin/sbin/newrepo | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'pinyadmin/sbin/newrepo') diff --git a/pinyadmin/sbin/newrepo b/pinyadmin/sbin/newrepo index a13a0dc..8f13873 100755 --- a/pinyadmin/sbin/newrepo +++ b/pinyadmin/sbin/newrepo @@ -3,26 +3,35 @@ use strict; use warnings; +use Getopt::Tabular qw( ); + use Moose::Util::TypeConstraints qw( find_type_constraint ); use Piny; -my ( $batch, $name, $remote ); -if ( $ARGV[0] eq "--batch" ) { - ( $batch, $name, $remote ) = @ARGV; -} else { - ( $name, $remote ) = @ARGV; -}; +my ( $batch ) = ( 0 ); +my ( $name, $remote, $ikiwiki ); + +Getopt::Tabular::SetOptionPatterns( "(--)[\\w-]+", "(-)\\w" ); +Getopt::Tabular::SetHelpOption( "--help" ); +Getopt::Tabular::GetOptions( + [ + [ "--batch", "const", 1, \$batch, "enable batch mode, for use as a backend by other scripts" ], + [ "--enable-ikiwiki|--disable-ikiwiki", "boolean", 0, \$ikiwiki, "enable or disable creation of an ikiwiki site for this repo" ] + ], \@ARGV +) or exit( 0 ); + +( $name, $remote ) = @ARGV; if ( not defined $name ) { - print "Usage: newrepo REPONAME\n"; - exit 1; + print( "Usage: newrepo REPONAME\n" ); + exit( 1 ); }; if ( not find_type_constraint( "Reponame" )->check( $name ) ) { print "That is not a valid repo name; must be at least 1 character long, begin with a lowercase alphanumeric character, and contain only alphanumeric characters and dashes.\n"; - exit 1; + exit( 2 ); }; my $description; @@ -33,8 +42,8 @@ while( 1 ) { if ( not find_type_constraint( "SimpleText" )->check( $description ) ) { print "Must be 1-80 characters long; control characters (including tab) not allowed.\n"; - if ( defined $batch ) { - exit; + if ( $batch ) { + exit( 3 ); }; next; }; @@ -74,5 +83,20 @@ if( defined( $remote ) ) { $repo = Piny::Repo->create( $name, $description ); }; -print "Repo URL: " . $repo->ikiwiki_url . "\n"; -print "Repo URL: " . $repo->cgit_url . "\n"; +$repo->rebuild_git; + +if ( defined( $ikiwiki ) ) { + $repo->config->piny_ikiwiki( $ikiwiki ); + if ( $repo->config->piny_ikiwiki ne $ikiwiki ) { + print( "Override in place for piny.ikiwiki.\n" ); + }; +}; + +if ( $repo->config->piny_ikiwiki ) { + $repo->rebuild_ikiwiki; + print( "Repo URL: " . $repo->ikiwiki_url . "\n" ); +} else { + print( "Ikiwiki disabled.\n" ); +}; + +print( "Repo URL: " . $repo->cgit_url . "\n" ); -- cgit v1.2.3