Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--simulate opts with verbose value 1 #87

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bin/stow.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ directory.
=item --verbose[=N]

Send verbose output to standard error describing what Stow is
doing. Verbosity levels are from 0 to 5; 0 is the default.
doing. Verbosity levels are from 0 to 5; 0 is the default or
1 if using C<--simulate>.
Using C<-v> or C<--verbose> increases the verbosity by one; using
`--verbose=N' sets it to N.

Expand Down Expand Up @@ -574,11 +575,19 @@ sub parse_options {
GetOptionsFromArray(
\@_,
\%options,
'verbose|v:+', 'help|h', 'simulate|n|no',
'verbose|v:+', 'help|h',
'version|V', 'compat|p', 'dir|d=s', 'target|t=s',
'adopt', 'no-folding', 'dotfiles',

# clean and pre-compile any regex's at parse time
'simulate|n|no' =>
sub {
$options{simulate} = 1;
unless (exists $options{verbose}) {
$options{verbose} = 1;
}
},

'ignore=s' =>
sub {
my $regex = $_[1];
Expand Down
27 changes: 26 additions & 1 deletion t/cli_options.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use strict;
use warnings;

use Test::More tests => 10;
use Test::More tests => 13;

use testutil;

Expand Down Expand Up @@ -109,4 +109,29 @@ make_path("$TEST_DIR/".'$HOME');
is($options->{target}, "$TEST_DIR/".'$HOME', 'no expansion');
remove_dir("$TEST_DIR/".'$HOME');

#
# Check if verbose on simulate invoked option
gutierri marked this conversation as resolved.
Show resolved Hide resolved
#
local @ARGV = (
'--simulate',
'-d', "$TEST_DIR/stow",
'-t', "$TEST_DIR/target",
'dummy'
);

my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
is($options->{simulate}, 1, 'simulate|no|n option');
is($options->{verbose}, 1, 'verbose option');

local @ARGV = (
'--simulate',
'-v3',
'-d', "$TEST_DIR/stow",
'-t', "$TEST_DIR/target",
'dummy'
);

my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
is($options->{verbose}, 3, 'verbose option');

# vim:ft=perl