diff options
author | Joe Rayhawk <jrayhawk@omgwallhack.org> | 2011-06-01 03:20:33 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@omgwallhack.org> | 2011-06-01 03:20:33 -0700 |
commit | 28c9853a2cb8b789eaecf76ed18b4230eee45ca4 (patch) | |
tree | 99d410a873a681dcce61ce597f6ceddc6539d9ba /pinyadmin/sbin | |
parent | 18c3275a222e57e6b98932e8e394646382b25388 (diff) | |
download | piny-code-28c9853a2cb8b789eaecf76ed18b4230eee45ca4.tar.gz piny-code-28c9853a2cb8b789eaecf76ed18b4230eee45ca4.zip |
newrepo: migrating rebuild logic out of Repo.pm and making --enable/disable-ikiwiki work
Diffstat (limited to 'pinyadmin/sbin')
-rwxr-xr-x | pinyadmin/sbin/newrepo | 50 |
1 files changed, 37 insertions, 13 deletions
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" ); |