Skip to content

Commit

Permalink
Add showconfig command (#225)
Browse files Browse the repository at this point in the history
* Make foreach function calls consistent

* Add showconfig command

* Output config as ASCII or HTML

---------

Co-authored-by: Tobias Oetiker <[email protected]>
  • Loading branch information
zaucker and oetiker authored Feb 20, 2024
1 parent 950fe4d commit eb62d87
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

- Add command showconfig to show print pod from Config.pm

0.49.1 2024-02-19 14:50:15 +0100 Tobias Oetiker <[email protected]>


- Add menuButtonSet and menuLabel to Actions.js to allow
separate config of mobile and regular menus
- Translate tooltip and placeholder in Card.js
Expand Down
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ WriteMakefile(
'Text::CSV' => 0,
'Excel::Writer::XLSX' => 0,
'Test::Fatal' => 0,
'Pod::Simple::Text' => 0,
'Pod::Simple::HTML' => 0,
},
BUILD_REQUIRES => {
'CPAN::Uploader' => 0
Expand Down
3 changes: 3 additions & 0 deletions lib/CallBackery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ sub startup {
}
}

## commands
unshift @{$app->commands->namespaces}, __PACKAGE__.'::Command';

unshift @{$app->static->paths},
$app->home->rel_file('frontend').'/compiled/source/'
if $app->mode eq 'development'; # Router
Expand Down
81 changes: 81 additions & 0 deletions lib/CallBackery/Command/showconfig.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package CallBackery::Command::showconfig;

use Mojo::Base 'Mojolicious::Command', -signatures;
use Getopt::Long qw(GetOptionsFromArray :config no_auto_abbrev no_ignore_case);
use Pod::Usage;
use Pod::Simple::Text;
use Pod::Simple::HTML;

has description => "showconfig\n";
has usage => <<"EOF";
Usage: $0 showconfig [options]
--verbose
--help
--html output as html
EOF

my %opt;

sub run ($self, @args) {
my $app = $self->app;

GetOptionsFromArray \@args, \%opt,qw(help verbose html) or exit 1;

$app->log->level($opt{verbose} ? 'debug' : 'info');

if ($opt{help}) { die $self->usage }

$opt{html} ? Pod::Simple::HTML->filter(\$app->config->pod)
: Pod::Simple::Text->filter(\$app->config->pod);


return;
}

1;

__END__
=head1 NAME
showconfig - show config documentation as pod
=head1 SYNOPSIS
APPLICATION B<showconfig> [--verbose] [--help] [--html]
=head1 DESCRIPTION
Parse the .cfg file definition and output documentation as pod
=head1 COPYRIGHT
Copyright (c) 2024- by OETIKER+PARTNER AG. All rights reserved.
=head1 LICENSE
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
=head1 AUTHOR
S<Fritz Zaucker E<lt>[email protected]E<gt>>
=head1 HISTORY
2024-02-19 fz Initial
=cut
2 changes: 1 addition & 1 deletion lib/CallBackery/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ FOOTER
my $header = <<"HEADER";
${E}head1 NAME
callbackery.cfg - The Apliance FRONTEND Builder config file
callbackery.cfg - The Appliance FRONTEND Builder config file
${E}head1 SYNOPSIS
Expand Down

0 comments on commit eb62d87

Please sign in to comment.