App-Sqitch

 view release on metacpan or  search on metacpan

lib/App/Sqitch/Command/config.pm  view on Meta::CPAN

    try {
        $self->sqitch->config->rename_section(
            from     => $old_name,
            to       => $new_name,
            filename => $self->file
        );
    }
    catch {
        hurl config => __ 'No such section!' if /\Qno such section/i;
        hurl config => $_;
    };
    return $self;
}

sub remove_section {
    my ( $self, $section ) = @_;
    $self->usage('Wrong number of arguments.')
        unless defined $section && $section ne '';
    try {
        $self->sqitch->config->remove_section(
            section  => $section,
            filename => $self->file
        );
    }
    catch {
        hurl config => __ 'No such section!' if /\Qno such section/i;
        hurl config => $_;
    };
    return $self;
}

sub _touch_dir {
    my $self = shift;
    unless ( -e $self->file ) {
        require File::Basename;
        my $dir = File::Basename::dirname( $self->file );
        unless ( -e $dir && -d _ ) {
            require File::Path;
            File::Path::make_path($dir);
        }
    }
}

1;

__END__

=head1 Name

App::Sqitch::Command::config - Get and set local, user, or system Sqitch options

=head1 Synopsis

  my $cmd = App::Sqitch::Command::config->new(\%params);
  $cmd->execute;

=head1 Description

You can query/set/replace/unset Sqitch options with this command. The name is
actually the section and the key separated by a dot, and the value will be
escaped.

=head1 Interface

=head2 Class Methods

=head3 C<options>

  my @opts = App::Sqitch::Command::config->options;

Returns a list of L<Getopt::Long> option specifications for the command-line
options for the C<config> command.

=head3 C<configure>

  my $params = App::Sqitch::Command::config->configure(
      $config,
      $options,
  );

Processes the configuration and command options and returns a hash suitable
for the constructor. Exits with an error on option specification errors.

=head2 Constructor

=head3 C<new>

  my $config = App::Sqitch::Command::config->new($params);

Creates and returns a new C<config> command object. The supported parameters
include:

=over

=item C<sqitch>

The core L<Sqitch|App::Sqitch> object.

=item C<file>

Configuration file to read from and write to.

=item C<action>

The action to be executed. May be one of:

=over

=item * C<get>

=item * C<get-all>

=item * C<get-regexp>

=item * C<set>

=item * C<add>

=item * C<replace-all>

=item * C<unset>



( run in 0.527 second using v1.01-cache-2.11-cpan-ceb78f64989 )