Skip to content

Instantly share code, notes, and snippets.

@kraih
Created March 17, 2012 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kraih/2062679 to your computer and use it in GitHub Desktop.
Save kraih/2062679 to your computer and use it in GitHub Desktop.
package Mojolicious::Command::files;
use Mojo::Base 'Mojo::Command';
use Mojo::Home;
has description => "List templates and static files.\n";
has usage => "usage: $0 files\n";
sub run {
my $self = shift;
# Find all DATA files
my $app = $self->app;
my $renderer = $app->renderer;
my $static = $app->static;
my @classes = @{$renderer->classes}, @{$static->classes};
for my $class (keys %{{map { $_ => 1 } @classes}}) {
my @files = sort keys %{$self->get_all_data($class) || {}};
say join("\n", "$class:", @files) if @files;
}
# Find all real files
my @paths = @{$renderer->paths}, @{$static->paths};
for my $path (keys %{{map { $_ => 1 } @paths}}) {
my @files = sort @{Mojo::Home->new($path)->list_files};
say join("\n", "$path:", @files) if @files;
}
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment