Permalink
Browse files

Add --local to config command.

Also rename project_file to local_file, so all is consistent.
  • Loading branch information...
1 parent ac99e9e commit 2c88ec9298cddd486dd8f5525b5e57c65b539a4f @theory committed Apr 27, 2012
Showing with 130 additions and 51 deletions.
  1. +2 −0 Changes
  2. +16 −18 lib/App/Sqitch/Command/config.pm
  3. +1 −1 lib/App/Sqitch/Command/init.pm
  4. +5 −5 lib/App/Sqitch/Config.pm
  5. +1 −0 lib/sqitch-config-usage.pod
  6. +26 −15 lib/sqitch-config.pod
  7. +69 −7 t/config.t
  8. +4 −4 t/configuration.t
  9. +1 −1 t/init.t
  10. +5 −0 t/local.conf
View
@@ -1,6 +1,8 @@
Revision history for Perl extension App::Sqitch
0.12
+ - Added `--local` option to `sqitch config`.
+ - Renamed `project_file()` to `--local_file()` in App::Sqitch::Config.
0.11 2012-04-27T06:44:54Z
- Implemented `init` command.
@@ -16,7 +16,7 @@ our $VERSION = '0.12';
has file => (is => 'ro', lazy => 1, default => sub {
my $self = shift;
- my $meth = $self->context . '_file';
+ my $meth = ($self->context || 'local') . '_file';
return $self->sqitch->config->$meth;
});
@@ -34,8 +34,8 @@ has action => (is => 'ro', isa => enum([qw(
rename-section
remove-section
)]));
-has context => (is => 'ro', required => 1, default => 'project', isa => enum([qw(
- project
+has context => (is => 'ro', isa => maybe_type enum([qw(
+ local
user
system
)]));
@@ -44,6 +44,7 @@ has type => (is => 'ro', isa => enum([qw(int num bool bool-or-int)]));
sub options {
return qw(
file|config-file|f=s
+ local
user
system
@@ -70,7 +71,7 @@ sub configure {
my ($class, $config, $opt) = @_;
# Make sure we are accessing only one file.
- my @file = grep { $opt->{$_} } qw(user system file);
+ my @file = grep { $opt->{$_} } qw(local user system file);
$class->usage('Only one config file at a time.') if @file > 1;
# Make sure we have only one type.
@@ -94,7 +95,7 @@ sub configure {
$class->usage('Only one action at a time.') if @action > 1;
# Get the action and context.
- my $context = first { $opt->{$_} } qw(user system);
+ my $context = first { $opt->{$_} } qw(local user system);
# Make it so.
return {
@@ -272,9 +273,9 @@ sub unset_all {
sub list {
my $self = shift;
- my $config = $self->context eq 'project'
- ? $self->sqitch->config
- : $self->_file_config;
+ my $config = $self->context
+ ? $self->_file_config
+ : $self->sqitch->config;
$self->emit(scalar $config->dump) if $config;
return $self;
}
@@ -342,7 +343,7 @@ __END__
=head1 Name
-App::Sqitch::Command::config - Get and set project, user, or system Sqitch options
+App::Sqitch::Command::config - Get and set local, user, or system Sqitch options
=head1 Synopsis
@@ -437,16 +438,14 @@ The configuration file context. Must be one of:
=over
-=item * C<project>
+=item * C<local>
=item * C<user>
=item * C<system>
=back
-Defaults to C<project>.
-
=item C<type>
The type to cast a value to be set to or fetched as. May be one of:
@@ -561,16 +560,17 @@ Removes a section. Exits with an error if the section does not exist.
$config->list;
-Lists all of the values in the configuration. If the context is C<system> or
-C<user>, only the settings set for that context will be emitted. Otherwise,
-all settings will be listed.
+Lists all of the values in the configuration. If the context is C<local>,
+C<user>, or C<system>, only the settings set for that context will be emitted.
+Otherwise, all settings will be listed.
=head3 C<edit>
$config->edit;
Opens the context-specific configuration file in a text editor for direct
-editing. The editor is determined by L<Sqitch/editor>.
+editing. If no context is specified, the local config file will be opened. The
+editor is determined by L<Sqitch/editor>.
=head2 Instance Accessors
@@ -603,8 +603,6 @@ The Sqitch command-line client.
=item * Make exit codes the same as C<git-config>.
-=item * Implement C<--local>.
-
=back
=head1 Author
@@ -41,7 +41,7 @@ sub write_config {
my $sqitch = $self->sqitch;
my $meta = $sqitch->meta;
my $config = $sqitch->config;
- my $file = $config->project_file;
+ my $file = $config->local_file;
if (-f $file) {
# Do nothing? Update config?
return $self;
@@ -35,12 +35,12 @@ sub user_file {
return file $hd, '.sqitch', shift->confname;
}
-sub project_file {
+sub local_file {
return $ENV{SQITCH_CONFIG} if $ENV{SQITCH_CONFIG};
return file +File::Spec->curdir, shift->confname;
}
-sub dir_file { shift->project_file }
+sub dir_file { shift->local_file }
sub get_section {
my ($self, %p) = @_;
@@ -95,15 +95,15 @@ Returns the path to the user configuration file. The value returned will be
the contents of the C<$SQITCH_USER_CONFIG> environment variable, if it's
defined, or else C<~/.sqitch/sqitch.conf>.
-=head3 C<project_file>
+=head3 C<local_file>
-Returns the path to the project configuration file, which is just
+Returns the path to the local configuration file, which is just
F<./sqitch.conf>, unless C<$SQITCH_CONFIG> is set, in which case its value
will be returned.
=head3 C<dir_file>
-An alias for C<project_file()> for use by the parent class.
+An alias for C<local_file()> for use by the parent class.
=head3 C<get_section>
@@ -10,6 +10,7 @@ sqitch-config-usage - Sqitch config usage statement
Config file location
+ --local use local config file
--user use user config file
--system use system config file
--local use repository config file
View
@@ -1,6 +1,6 @@
=head1 Name
-sqitch-config - Get and set project, user, or system Sqitch options
+sqitch-config - Get and set local, user, or system Sqitch options
=head1 Synopsis
@@ -36,10 +36,10 @@ form (simple integer for C<--int>, decimal number for C<--num>, a "true" or
"false" string for C<--bool>) If no type specifier is passed, no checks or
transformations are performed on the value.
-The C<file-option> can be one of C<--system>, C<--user> or C<--file>, which
-specify where the values will be read from or written to. The default is to
-assume the config file of the current project directory, F<./sqitch.conf>
-(see L<Files>).
+The C<file-option> can be one of C<--local>, C<--user>, C<--system>, or
+C<--file>, which specify where the values will be read from or written to. The
+default is to assume the local config file in the current project directory,
+for editing, and the all files merged for fetching (see L<Files>).
=begin comment
@@ -117,6 +117,16 @@ exactly one.
Like C<--get-all>, but interprets the name as a regular expression and writes
out the key names and value.
+=item C<--local>
+
+For writing options: write to the local F<./sqitch.conf> file. This is
+the default if no file option is specified.
+
+For reading options: read only from the local F<./sqitch.conf> file rather
+than from all available files.
+
+See also L<Files>.
+
=item C<--user>
For writing options: write to the user F<~/.sqitch/sqitch.conf> file rather
@@ -180,8 +190,9 @@ C<--bool> or C<--int>, as described above.
=item C<-e, --edit>
-Opens an editor to modify the specified config file; either C<--system>,
-C<--user>, or repository (default).
+Opens an editor to modify the specified config file; either C<--local>,
+C<--user>, C<--system>, or C<--file>. If none of those options is specified,
+the local file will be opened.
=back
@@ -194,7 +205,7 @@ C<sqitch config> will search for configuration options:
=item C<./sqitch.conf>
-Project-specific configuration file.
+Local, project-specific configuration file.
=item C<~/.sqitch/sqitch.conf>
@@ -212,8 +223,7 @@ System-wide configuration file.
=item C<SQITCH_CONFIG>
-Take the project configuration from the given file instead of
-C<./sqitch.conf>.
+Take the local configuration from the given file instead of C<./sqitch.conf>.
=item C<SQITCH_USER_CONFIG>
@@ -306,11 +316,12 @@ To add a new setting without altering any of the existing ones, use:
=head1 Configuration File
The sqitch configuration file contains a number of variables that affect the
-sqitch command's behavior. The F<./sqitch.conf> file in each project is used
-to store the configuration for that project, and F<$HOME/.sqitch/sqitch.conf>
-is used to store a per-user configuration as fallback values for the
-F<./sqitch.conf> file. The file F<$(prefix>/etc/sqitch.conf> can be used to
-store a system-wide default configuration.
+sqitch command's behavior. The F<./sqitch.conf> file local to each project is
+used to store the configuration for that project, and
+F<$HOME/.sqitch/sqitch.conf> is used to store a per-user configuration as
+fallback values for the F<./sqitch.conf> file. The file
+F<$(prefix>/etc/sqitch.conf> can be used to store a system-wide default
+configuration.
The variables are divided into sections, wherein the fully qualified variable
name of the variable itself is the last dot-separated segment and the section
Oops, something went wrong.

0 comments on commit 2c88ec9

Please sign in to comment.