chiark / gitweb /
bin/pastebin.userv: New `langs' subcommand prints language names.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 3 Feb 2017 10:53:28 +0000 (10:53 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 3 Feb 2017 10:53:28 +0000 (10:53 +0000)
bin/pastebin.userv

index 42dc66d..c9936ed 100755 (executable)
@@ -32,11 +32,21 @@ Commands available:
        del TAG ...
        get TAG
        help
+       langs
        list
        new [-l LANG] [-t TITLE]
        rekey TAG
        update [-c] [-l LANG] [-t TITLE] TAG
 EOF
+} elsif ($op eq "langs") {
+  @ARGV == 0 or Odin::fail "usage: list";
+  my $db = Odin::open_db;
+  for my $r (@{$db->selectall_arrayref
+               ("SELECT lang, descr FROM odin_pastebin_lang
+                 ORDER BY lang", undef)}) {
+    my ($lang, $descr) = @$r;
+    Odin::print_columns $lang => 16, $descr => 0;
+  }
 } elsif ($op eq "list") {
   @ARGV == 0 or Odin::fail "usage: list";
   my $db = Odin::open_db;