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

lib/Rex/CLI.pm: display a warning when/if Rex::Template is loaded. #1512

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 25 additions & 2 deletions lib/Rex/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use Rex::TaskList;
use Rex::Logger;
use YAML;

use Data::Dumper;

Comment on lines -33 to -34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why Data::Dumper is also removed in this context about Rex::Template::* deprecation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is unused in CLI.pm.

my $no_color = 0;
eval "use Term::ANSIColor";
if ($@) { $no_color = 1; }
Expand Down Expand Up @@ -197,6 +195,7 @@ FORCE_SERVER: {

load_server_ini_file($::rexfile);
load_rexfile($::rexfile);
check_template_modules();

#### check if some parameters should be overwritten from the command line
CHECK_OVERWRITE: {
Expand Down Expand Up @@ -455,6 +454,30 @@ sub __help__ {

}

# Check whether Rex/Template.pm
# or Rex/Template/NG.pm modules are loaded. If there are,
# they should be present in the %INC hash.
sub check_template_modules {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have Rex::deprecated to mark things deprecated in Rex core in a uniform way. That might come in handy here too. Or perhaps during import time of Rex::Template and Rex::Template::NG.

my @tpl_modules_loaded =
grep { /(Rex\/Template|Rex\/Template\/NG)/ } keys %INC;
if ( scalar @tpl_modules_loaded > 0 ) {
Rex::Logger::info(
"WARNING! You are using Rex built-in template engine aka Rex::Template.",
"warn"
);
Rex::Logger::info(
"This engine is obsolete, unmaintained and will be retired in future releases.",
"warn"
);
monsieurp marked this conversation as resolved.
Show resolved Hide resolved
Rex::Logger::info(
"Please consider migrating to a more modern template engine.", "warn" );
Rex::Logger::info(
"Text::Template::Simple, Template::Toolkit, etc. As usual, CPAN is you friend.",
"warn"
);
Comment on lines +472 to +477
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about pointing to Rex::Template::TT as a readily available and recommended external module, and point to the docs about how to set one's own custom templating functions:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that indeed.

}
}

sub add_help {
my ( $self, $code ) = @_;
push( @help, $code );
Expand Down