Permalink
Browse files

Replace engine set-* actions with alter action.

Will make it easier to modify engine properties, including many at once. The
set-* actions are now deprecated, and emit a warning, except for the
`set-reworked*` actions, which are simply removed (never released).
  • Loading branch information...
theory committed Aug 6, 2015
1 parent e0e0342 commit a2db9a29435e7df874b98df601a7a6d877d22337
Showing with 159 additions and 114 deletions.
  1. +4 −0 Changes
  2. +47 −4 lib/App/Sqitch/Command/engine.pm
  3. +10 −10 lib/sqitch-configuration.pod
  4. +2 −10 lib/sqitch-engine-usage.pod
  5. +8 −68 lib/sqitch-engine.pod
  6. +1 −1 t/engine.t
  7. +87 −21 t/engine_cmd.t
@@ -30,6 +30,10 @@ Revision history for Perl extension App::Sqitch
`deploy_dir`, `revert_dir`, or `verify_dir` settings. I think these
settings are not commonly used, and it would start to get crowded if we
also added their "reworked" variants, which will be used still less.
- Added the `alter` action to the `engine` command to set engine
properties.
- Deprecated the `set-*` actions in the `engine` command in favor of the
new `alter` action.
- Added support for setting reworked directories to the `engine` command.
- Reformatted the output of the `engine` command's `show` action include
reworked directories, and to bit a bit less flat.
@@ -141,10 +141,47 @@ sub add {
return $self;
}

sub alter {
my ($self, $engine, $target) = @_;
$self->usage unless $engine;
_chk_engine $engine;

my $key = "engine.$engine";
my $config = $self->sqitch->config;
my $props = $self->properties;

hurl engine => __x(
'Missing Engine "{engine}"; use "{command}" to add it',
engine => $engine,
command => "add $engine " . ($props->{target} || "db:$engine:"),
) unless $config->get( key => "engine.$engine.target");

my @vars;
while (my ($prop, $val) = each %{ $props } ) {
my $normalizer = $normalizer_for{$prop} or $self->usage(__x(
'Unknown property "{property}"',
property => $prop,
));
push @vars => {
key => "$key.$prop",
value => $normalizer->($val, $config),
};
}

# Make it so.
$config->group_set( $config->local_file, \@vars );
}

# XXX Remove deprecated _set method and everything that uses it.
sub _set {
my ($self, $key, $engine, $value) = @_;
(my $action = $key) =~ s/_/-/g;
$self->usage unless $engine && $value;
$self->sqitch->warn(__x(
qq{ The "{old}" action is deprecated;\n Instead use "{new}".},
old => "set-$action $engine $value",
new => "alter $engine --set $action=$value",
));

_chk_engine $engine;

@@ -183,10 +220,6 @@ sub set_top_dir { shift->_set_dir('top_dir', @_) }
sub set_deploy_dir { shift->_set_dir('deploy_dir', @_) }
sub set_revert_dir { shift->_set_dir('revert_dir', @_) }
sub set_verify_dir { shift->_set_dir('verify_dir', @_) }
sub set_reworked_dir { shift->_set_dir('reworked_dir', @_) }
sub set_reworked_deploy_dir { shift->_set_dir('reworked_deploy_dir', @_) }
sub set_reworked_revert_dir { shift->_set_dir('reworked_revert_dir', @_) }
sub set_reworked_verify_dir { shift->_set_dir('reworked_verify_dir', @_) }

sub set_plan_file {
my ($self, $engine, $file) = @_;
@@ -419,6 +452,10 @@ Executes the C<engine> command.
Implements the C<add> action.
=head3 C<alter>
Implements the C<alter> action.
=head3 C<list>
Implements the C<list> action.
@@ -429,6 +466,10 @@ Implements the C<list> action.
Implements the C<remove> action.
=begin comment
Deprecated methods.
=head3 C<set_target>
Implements the C<set-target> action.
@@ -481,6 +522,8 @@ Implements the C<set-reworked-verify-dir> action.
Implements the C<set-extension> action.
=end comment
=head3 C<show>
Implements the C<show> action.
@@ -257,7 +257,7 @@ share the same plan. In that case, we should move the plan file out of the
PostgreSQL directory:

> mv pg/sqitch.plan .
> sqitch engine set-plan-file pg sqitch.plan
> sqitch engine pg --set plan_file=sqitch.plan
> sqitch engine show pg
* pg
Target: db:pg:
@@ -498,7 +498,7 @@ its value will be determined by examining each of the following in turn:
=item C<engine.$engine.target>

sqitch engine add $engine --set target=$target
sqitch engine set-target $engine $target
sqitch engine alter $engine --set=$target

=item C<core.target>

@@ -546,7 +546,7 @@ can specify it via the following:
=item C<engine.$engine.client>

sqitch engine add $engine --set client=$client
sqitch engine set-client $engine $client
sqitch engine alter $engine --set client=$client
sqitch config --user engine.$engine.client $client

=item C<core.client>
@@ -576,7 +576,7 @@ the following:
=item C<engine.$engine.registry>

sqitch engine add $engine --set registry=$registry
sqitch engine set-registry $engine $registry
sqitch engine alter $engine --set registry=$registry

=item C<core.registry>

@@ -604,7 +604,7 @@ you need a custom directory, specify it via the following:
=item C<engine.$engine.top_dir>

sqitch engine add $engine --set top_dir=$top_dir
sqitch engine set-top-dir $engine $top_dir
sqitch engine alter $engine --set=top_dir=$top_dir

=item C<core.top_dir>

@@ -631,7 +631,7 @@ If you need a different file, specify it via the following:
=item C<engine.$engine.plan_file>

sqitch engine add $engine --set plan_file=$plan_file
sqitch engine set-plan-file $engine $plan_file
sqitch engine alter $engine --set plan_file=$plan_file

=item C<core.plan_file>

@@ -655,7 +655,7 @@ following:
=item C<engine.$engine.deploy_dir>

sqitch engine add $engine --set deploy_dir=$deploy_dir
sqitch engine set-deploy-dir $engine $deploy_dir
sqitch engine alter --set deploy_dir=$deploy_dir

=item C<core.deploy_dir>

@@ -682,7 +682,7 @@ following:
=item C<engine.$engine.revert_dir>

sqitch engine add $engine --set revert_dir=$revert_dir
sqitch engine set-revert-dir $engine $revert_dir
sqitch engine alter --set revert_dir=$revert_dir

=item C<core.revert_dir>

@@ -706,7 +706,7 @@ following:
=item C<engine.$engine.verify_dir>

sqitch engine add $engine --set verify_dir=$verify_dir
sqitch engine set-verify-dir $engine $verify_dir
sqitch engine alter $engine --set verify_dir=$verify_dir

=item C<core.verify_dir>

@@ -730,7 +730,7 @@ following:
=item C<engine.$engine.extension>

sqitch engine add $engine --set extension=$extension
sqitch engine set-extension $engine $extension
sqitch engine alter $engine --set extension=$extension

=item C<core.extension>

@@ -6,20 +6,12 @@ sqitch-engine-usage - Sqitch engine usage statement

sqitch [options] engine
sqitch engine add <name> [-s <property>=<value> ...]
sqitch engine set-target <name> <target>
sqitch engine set-registry <name> <registry>
sqitch engine set-client <name> <client>
sqitch engine set-top-dir <name> <directory>
sqitch engine set-plan-file <name> <file>
sqitch engine set-deploy-dir <name> <directory>
sqitch engine set-revert-dir <name> <directory>
sqitch engine set-verify-dir <name> <directory>
sqitch engine set-extension <name> <extension>
sqitch engine alter <name> [-s <property>=<value> ...]
sqitch engine remove <name>
sqitch engine show <name>
sqitch engine update-config

=head1 Options

-v, --verbose be verbose; must be placed before an action
-s, --set KEY=VALUE set engine property when adding a engine
-s, --set KEY=VALUE set engine property when adding or altering
@@ -6,21 +6,9 @@ sqitch-engine - Manage database engine configuration

sqitch engine
sqitch engine add <name> <target> [-s <property>=<value> ...]
sqitch engine set-target <name> <target>
sqitch engine set-registry <name> <registry>
sqitch engine set-client <name> <client>
sqitch engine set-top-dir <name> <directory>
sqitch engine set-plan-file <name> <file>
sqitch engine set-deploy-dir <name> <directory>
sqitch engine set-revert-dir <name> <directory>
sqitch engine set-verify-dir <name> <directory>
sqitch engine set-reworked-dir <name> <directory>
sqitch engine set-reworked-deploy-dir <name> <directory>
sqitch engine set-reworked-revert-dir <name> <directory>
sqitch engine set-reworked-verify-dir <name> <directory>
sqitch engine set-extension <name> <extension>
sqitch engine alter <name> [-s <property>=<value> ...]
sqitch engine remove <name>
sqitch engine show <name>
sqitch engine show <name> [...]
sqitch engine update-config

=head1 Description
@@ -136,8 +124,8 @@ L<config|sqitch-config> options.

sqitch engine add pg -s top_dir=pg -s client=/usr/local/pgsql/bin/psql

Set a engine property key/value pair. May be specified multiple times. Used
only by the C<add> action. Supported keys are:
Set an engine property key/value pair. May be specified multiple times. Used
only by the C<add> and C<alter> actions. Supported keys are:

=over

@@ -178,61 +166,13 @@ available to perform operations on the engines.

=head2 C<add>

Add a engine named C<< <name> >> for the database at C<< <uri> >>. The
Add an engine named C<< <name> >> for the database at C<< <uri> >>. The
C<--set> option specifies engine-specific properties.

=head2 C<alter>

=head2 C<set-target>

Set the target for engine C<< <name> >>.

=head2 C<set-registry>

Set the registry for engine C<< <name> >>.

=head2 C<set-client>

Set the client for engine C<< <name> >>.

=head2 C<set-top-dir>

Set the top directory for engine C<< <name> >>.

=head2 C<set-plan-file>

Set the plan file for engine C<< <name> >>.

=head2 C<set-deploy-dir>

Set the deploy directory for engine C<< <name> >>.

=head2 C<set-revert-dir>

Set the revert directory for engine C<< <name> >>.

=head2 C<set-verify-dir>

Set the verify directory for engine C<< <name> >>.

=head2 C<set-reworked-dir>

Set the reworked directory for engine C<< <name> >>.

=head2 C<set-reworked-deploy-dir>

Set the reworked deploy directory for engine C<< <name> >>.

=head2 C<set-reworked-revert-dir>

Set the reworked revert directory for engine C<< <name> >>.

=head2 C<set-reworked-verify-dir>

Set the reworked verify directory for engine C<< <name> >>.

=head2 C<set-extension>

Set the extension for engine C<< <name> >>.
Alter an engine named C<< <name> >>. The C<--set> option specifies
engine-specific properties to set.

=head2 C<remove>, C<rm>

@@ -47,7 +47,7 @@ my ( $earliest_change_id, $latest_change_id, $initialized );
my $registry_version = $CLASS->registry_release;
my $script_hash;
ENGINE: {
# Stub out a engine.
# Stub out an engine.
package App::Sqitch::Engine::whu;
use Moo;
use App::Sqitch::X qw(hurl);
Oops, something went wrong.

0 comments on commit a2db9a2

Please sign in to comment.