From 5268ca832db7528ea1c80af167006381c9c4bb0d Mon Sep 17 00:00:00 2001 From: Gutierri Barboza Date: Thu, 15 Apr 2021 13:17:46 -0300 Subject: [PATCH 1/3] when called --simulate, verbose by default has value 1 --- bin/stow.in | 10 +++++++++- t/cli_options.t | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index 76b150c..e0f6f20 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -574,11 +574,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]; diff --git a/t/cli_options.t b/t/cli_options.t index 8b73bf5..ea2a723 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 12; use testutil; @@ -109,4 +109,18 @@ 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 +# +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'); + # vim:ft=perl From 06cf0afa5872fc8434d255774636b9c04189bcb5 Mon Sep 17 00:00:00 2001 From: Gutierri Barboza Date: Thu, 15 Apr 2021 20:43:43 -0300 Subject: [PATCH 2/3] tests verbose with simulate opts --- t/cli_options.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/cli_options.t b/t/cli_options.t index ea2a723..cfb4db0 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 13; use testutil; @@ -123,4 +123,15 @@ 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 From c3ca927279247e5becb2b66ac8203e846c72869a Mon Sep 17 00:00:00 2001 From: Gutierri Barboza Date: Thu, 15 Apr 2021 21:10:04 -0300 Subject: [PATCH 3/3] more docs about --verbose with --simulate --- bin/stow.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index e0f6f20..4b1a15d 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -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.