Permalink
Browse files

introduce 'tapper init'

...to set up a $HOME/.tapper/ for user-specific
configuration and database.
  • Loading branch information...
renormalist committed Nov 7, 2012
1 parent 1bf18db commit b192f0c4ae631059e1e5af465a7849033eb60bda
Showing with 94 additions and 5 deletions.
  1. +3 −5 bin/tapper
  2. +91 −0 lib/Tapper/CLI/Init.pm
View
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# PODNAME: tapper
-# ABSTRACT: cmdline frontend to Tapper management - the future Platzhirsch
+# ABSTRACT: Tapper - primary cmdline frontend - the future Platzhirsch
use App::Rad;
use Tapper::CLI::Notification;
@@ -9,13 +9,12 @@ use Tapper::CLI::Schema;
use Tapper::CLI::User;
use Tapper::CLI::Host;
use Tapper::CLI::Cobbler;
-
+use Tapper::CLI::Init;
use strict;
use warnings;
use 5.010;
-
sub setup
{
my ($c) = @_;
@@ -25,8 +24,7 @@ sub setup
Tapper::CLI::User::setup($c);
Tapper::CLI::Host::setup($c);
Tapper::CLI::Cobbler::setup($c);
+ Tapper::CLI::Init::setup($c);
}
-
App::Rad->run();
-
View
@@ -0,0 +1,91 @@
+package Tapper::CLI::Init;
+
+use 5.010;
+use strict;
+use warnings;
+
+use Tapper::Cmd::Init;
+
+=head1 NAME
+
+Tapper::CLI::Init - Tapper - set up a user-specific $HOME/.tapper/
+
+=head1 SYNOPSIS
+
+This module is part of the Tapper::CLI framework. It is supposed to be
+used together with App::Rad. All following functions expect their
+arguments as $c->options->{$arg}.
+
+ use App::Rad;
+ use Tapper::CLI::Init;
+ Tapper::CLI::Init::setup($c);
+ App::Rad->run();
+
+=head1 FUNCTIONS
+
+=head2 init
+
+Initialize a $HOME/.tapper/ with tapper.cfg and initial SQLite database.
+
+=cut
+
+sub init
+{
+ my ($c) = @_;
+ $c->getopt( 'quiet|q', 'help|?', 'default|d' );
+
+ my $use_defaults = $c->options->{default};
+ if ( $c->options->{help} or not $use_defaults ) {
+ say STDERR "Usage: $0 init --default|d [ --quiet ]";
+ say STDERR "";
+ say STDERR " --default Use default values for all parameters (currently required)";
+ say STDERR " --quiet Stay silent.";
+ say STDERR " --help Print this help message and exit.";
+ exit -1;
+ }
+
+ my %options = ( $use_defaults ?
+ (
+ db => "SQLite",
+ )
+ : (
+ db => $c->options->{db},
+ ),
+ );
+
+ my $cmd = Tapper::Cmd::Init->new;
+ $cmd->init(\%options);
+ return;
+}
+
+
+=head2 setup
+
+Initialize the testplan functions for tapper CLI
+
+=cut
+
+sub setup
+{
+ my ($c) = @_;
+ $c->register('init', \&init, 'Initialize $HOME/.tapper/ for non-root use-cases.');
+ return;
+}
+
+=head1 AUTHOR
+
+AMD OSRC Tapper Team, C<< <tapper at amd64.org> >>
+
+=head1 BUGS
+
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2008-2011 AMD OSRC Tapper Team, all rights reserved.
+
+This program is released under the following license: freebsd
+
+
+=cut
+
+1; # End of Tapper::CLI

0 comments on commit b192f0c

Please sign in to comment.