Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.8 KiB

  1. #!/usr/bin/env perl
  2. =pod
  3. =head1 NAME
  4. wrt-config - show configuration values, including defaults
  5. =head1 USAGE
  6. wrt config
  7. # Specify a different config file:
  8. wrt config --config ./wrt.json ...
  9. =head1 DESCRIPTION
  10. C<wrt-config> displays configuration values for the current wrt repository,
  11. including both those overridden in the current F<wrt.json> and those set
  12. by default.
  13. For now, this just uses C<Data::Dumper>, and outputs a whole bunch of stuff
  14. that may not be very interesting, since basically all the values are jammed
  15. into a single object. Ideally, it could show which values are defaults and
  16. which have been set from a config file or derived from the structure of the
  17. archive.
  18. =head1 LICENSE
  19. wrt is free software; you can redistribute it and/or modify
  20. it under the terms of the GNU General Public License as published by
  21. the Free Software Foundation; either version 2 of the License, or
  22. (at your option) any later version.
  23. =head1 AUTHOR
  24. Brennen Bearnes <code@p1k3.com>
  25. =cut
  26. use 5.10.0;
  27. use strict;
  28. use warnings;
  29. no warnings 'uninitialized';
  30. use Data::Dumper;
  31. use App::WRT;
  32. use Carp;
  33. use Getopt::Long;
  34. use Pod::Usage;
  35. # Handle options, including help generated from the POD above. See:
  36. # - http://perldoc.perl.org/Getopt/Long.html#User-defined-subroutines-to-handle-options
  37. # - https://metacpan.org/pod/Pod::Usage
  38. # - http://michael.thegrebs.com/2014/06/08/Pod-Usage/
  39. my $config_file = 'wrt.json';
  40. GetOptions(
  41. 'config=s' => \$config_file,
  42. help => sub { pod2usage(0) },
  43. ) or pod2usage(2);
  44. unless (-e $config_file) {
  45. croak "No wrt config file found. Tried: $config_file";
  46. }
  47. my $w = App::WRT::new_from_file($config_file);
  48. # With --stdin, take names of entries to display from standard input, one line
  49. # per name. Otherwise, take names from arguments.
  50. print Dumper($w);
  51. exit(0);