File Coverage

blib/lib/App/Sqitch/Command/upgrade.pm
Criterion Covered Total %
statement 41 41 100.0
branch 3 4 75.0
condition n/a
subroutine 11 11 100.0
pod 1 1 100.0
total 56 57 98.2


line stmt bran cond sub pod time code
1             package App::Sqitch::Command::upgrade;
2              
3 2     2   1908 use 5.010;
  2         7  
4 2     2   11 use strict;
  2         10  
  2         57  
5 2     2   11 use warnings;
  2         11  
  2         52  
6 2     2   12 use utf8;
  2         4  
  2         23  
7 2     2   57 use Moo;
  2         7  
  2         27  
8 2     2   857 use App::Sqitch::Types qw(URI Maybe Str Bool HashRef);
  2         4  
  2         25  
9 2     2   2507 use Locale::TextDomain qw(App-Sqitch);
  2         6  
  2         14  
10 2     2   405 use App::Sqitch::X qw(hurl);
  2         4  
  2         18  
11 2     2   618 use List::Util qw(first);
  2         4  
  2         114  
12 2     2   20 use namespace::autoclean;
  2         5  
  2         18  
13             extends 'App::Sqitch::Command';
14             with 'App::Sqitch::Role::ConnectingCommand';
15              
16             our $VERSION = 'v1.4.0'; # VERSION
17              
18             has target => (
19             is => 'ro',
20             isa => Str,
21             );
22              
23             sub options {
24             return qw(
25             target|t=s
26             );
27             }
28              
29             sub execute {
30 5     5 1 7233 my $self = shift;
31 5         38 my ($targets) = $self->parse_args(
32             target => $self->target,
33             args => \@_,
34             );
35              
36             # Warn on multiple targets.
37 5         12 my $target = shift @{ $targets };
  5         10  
38             $self->warn(__x(
39             'Too many targets specified; using {target}',
40             target => $target->name,
41 5 50       7 )) if @{ $targets };
  5         12  
42              
43 5         113 my $engine = $target->engine;
44              
45 5 100       781 if ($engine->needs_upgrade) {
46 1         8 $self->info(__x(
47             'Upgrading registry {registry} to version {version}',
48             registry => $engine->registry_destination,
49             version => $engine->registry_release,
50             ));
51 1         143 $engine->upgrade_registry;
52             } else {
53 4         43 $self->info(__x(
54             'Registry {registry} is up-to-date at version {version}',
55             registry => $engine->registry_destination,
56             version => $engine->registry_release,
57             ));
58             }
59              
60 5         1169 return $self;
61             }
62              
63             1;
64              
65             __END__
66              
67             =head1 Name
68              
69             App::Sqitch::Command::upgrade - Upgrade the Sqitch registry
70              
71             =head1 Synopsis
72              
73             my $cmd = App::Sqitch::Command::upgrade->new(%params);
74             $cmd->execute;
75              
76             =head1 Description
77              
78             If you want to know how to use the C<upgrade> command, you probably want to be
79             reading C<sqitch-upgrade>. But if you really want to know how the C<upgrade>
80             command works, read on.
81              
82             =head1 Interface
83              
84             =head2 Class Methods
85              
86             =head3 C<options>
87              
88             my @opts = App::Sqitch::Command::upgrade->options;
89              
90             Returns a list of L<Getopt::Long> option specifications for the command-line
91             options for the C<upgrade> command.
92              
93             =head2 Attributes
94              
95             =head3 C<target>
96              
97             The upgrade target.
98              
99             =head2 Instance Methods
100              
101             =head3 C<execute>
102              
103             $upgrade->execute;
104              
105             Executes the upgrade command.
106              
107             =head1 See Also
108              
109             =over
110              
111             =item L<sqitch-upgrade>
112              
113             Documentation for the C<upgrade> command to the Sqitch command-line client.
114              
115             =item L<sqitch>
116              
117             The Sqitch command-line client.
118              
119             =back
120              
121             =head1 Author
122              
123             David E. Wheeler <david@justatheory.com>
124              
125             =head1 License
126              
127             Copyright (c) 2012-2023 iovation Inc., David E. Wheeler
128              
129             Permission is hereby granted, free of charge, to any person obtaining a copy
130             of this software and associated documentation files (the "Software"), to deal
131             in the Software without restriction, including without limitation the rights
132             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
133             copies of the Software, and to permit persons to whom the Software is
134             furnished to do so, subject to the following conditions:
135              
136             The above copyright notice and this permission notice shall be included in all
137             copies or substantial portions of the Software.
138              
139             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
140             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
141             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
142             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
143             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
144             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
145             SOFTWARE.
146              
147             =cut