aboutsummaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2018-12-29 16:20:05 -0200
committerEuAndreh <eu@euandre.org>2018-12-29 16:20:05 -0200
commita203ce1f68ebd36552d34290e03a319d6860bcde (patch)
tree2527f60fa8f92933681bc03f700f494895705289 /website
parentAdd =test= to default.nix and run in on CI. (diff)
downloadeuandre.org-a203ce1f68ebd36552d34290e03a319d6860bcde.tar.gz
euandre.org-a203ce1f68ebd36552d34290e03a319d6860bcde.tar.xz
Use Getopt::Long and Pod::Usage to build basic CLI.
Diffstat (limited to 'website')
-rwxr-xr-xwebsite92
1 files changed, 92 insertions, 0 deletions
diff --git a/website b/website
new file mode 100755
index 0000000..89d47b7
--- /dev/null
+++ b/website
@@ -0,0 +1,92 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i perl -p perl less nix --pure -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.09.tar.gz
+
+=head1 NAME
+
+website - Website repository CLI manager.
+
+=head1 SYNOPSIS
+
+website <subcommand> [options]
+
+ Subcommands:
+ pastebin Create a new pastebin from the org-mode template.
+ slides Create a new HTML slideshow from the existing templates.
+ test Run internal CLI tests.
+
+ Options:
+ --help Show the manpage.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-h, --help>
+
+Prints the manual page and exits.
+
+=back
+
+=head1 DESCRIPTION
+
+B<website> is the top-level coordinator of subtasks inside the website repo.
+
+=cut
+
+use strict;
+use warnings;
+use Getopt::Long qw(:config no_ignore_case bundling pass_through);
+use Pod::Usage qw(pod2usage);
+
+my $help = 0;
+my $title = '';
+sub getopts {
+ GetOptions(
+ 'help|h|?' => \$help
+ );
+}
+
+sub test {
+ die "FIXME";
+}
+
+sub dispatch {
+ my $action = shift;
+ my @args = @_;
+ my @sub_args = grep { $_ ne $action } @args;
+ if (!defined $action && $help) {
+ pod2usage(
+ -verbose => 2,
+ -exitval => 0
+ );
+ } elsif (!defined $action) {
+ print "Missing subcomand.\n";
+ pod2usage(
+ -verbose => 1,
+ -exitval => 2
+ );
+ } elsif ($action eq 'pastebin') {
+ print `./pastebin/website-pastebin @sub_args`;
+ exit $? >> 8;
+ } elsif ($action eq 'slides') {
+ print `./pastebin/website-slides @sub_args`;
+ exit $? >> 8;
+ } elsif ($action eq 'test') {
+ test();
+ } else {
+ print "Unknown subcommand: $action.\n";
+ pod2usage(
+ -verbose => 1,
+ -exitval => 2
+ );
+ }
+}
+
+sub main {
+ my @orig_args=@ARGV;
+ getopts();
+ my $action=shift @ARGV;
+ dispatch($action, @orig_args);
+}
+
+main();