--- /dev/null
+#!/usr/bin/env perl
+use 5.014;
+use warnings;
+use utf8;
+use re '/msx';
+use open OUT => ':utf8', ':std';
+
+our $VERSION = '1.00';
+
+say '# automatically generated by tools/mkclioptions';
+say '+{';
+
+for my $program (@ARGV) {
+ my $help = eval {
+ local $/;
+ open my $output, '-|', $program, '--help';
+ return readline $output;
+ } or next;
+
+ printf "%s => {\n", $program;
+
+ while ($help =~ m{ ^\h+ (-\N*?) (?: \h{3,} (\N*) )? \n }g) {
+ #TODO: continuations
+ my ($options, $explain) = ($1, $2);
+ my ($short) = $options =~ m{ (?<! \H) -([^-]) (?! [^,\h]) }
+ or next;
+ printf " ['%s', '%s', q{%s}]\n", $short, $options, $explain // '';
+ }
+
+ say '},';
+}
+
+say '}';
+
+__END__
+
+=head1 NAME
+
+mkclioptions
+
+=head1 SYNOPSIS
+
+ mkclioptions ls >clioptions.inc.pl
+
+=head1 AUTHOR
+
+Mischa POSLAWSKY <perl@shiar.org>
+
+=head1 LICENSE
+
+Licensed under the GNU Affero General Public License version 3.
+