X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/65faae1c253e37cb659e16966c18a07ca2822bd7..HEAD:/tools/mkclioptions diff --git a/tools/mkclioptions b/tools/mkclioptions index 54192b0..020f025 100755 --- a/tools/mkclioptions +++ b/tools/mkclioptions @@ -3,28 +3,60 @@ use 5.014; use warnings; use utf8; use re '/msx'; -use open OUT => ':utf8', ':std'; +use open OUT => ':encoding(utf-8)', ':std'; our $VERSION = '1.00'; +my %group = ( + core => [qw( + cat chgrp chmod chown cp date df ln ls mkdir mknod mktemp mv + readlink rm rmdir touch uname + )], + usr => [qw( + base64 basename chcon cksum comm csplit cut dircolors + dirname du env expand expr factor fmt fold groups head hostid id + install join link logname md5sum mkfifo nice nl nohup nproc numfmt od + paste pathchk pinky pr printenv printf ptx realpath runcon seq sha1sum + shred shuf sort split stat + stdbuf sum tac tail tee test timeout tr truncate tsort tty unexpand + uniq unlink users wc who whoami yes + )], + -usr => [qw( + base32 b2sum sha224sum sha256sum sha384sum sha512sum + )], + bsd => [qw( + calendar col column hexdump look ncal + )], + more => [qw( + find xargs free skill htop uptime watch sed awk perl figlet less + curl wget ping fping ssh nc + )], + corerest => [qw( + dd pwd sleep stty sync + )], + git => [map {"git $_"} qw( log status )], +); + say '# automatically generated by tools/mkclioptions'; say '+{'; -for my $program (@ARGV) { +for my $program (map { $group{$_} ? @{$group{$_}} : $_ } @ARGV) { my $help = eval { local $/; - open my $output, '-|', $program, '--help'; + open my $output, '-|', split(/\h/, $program), '--help'; + warn "$program exited with status $?\n" if $?; return readline $output; } or next; - printf "%s => {\n", $program; + 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{ (? [q{%s}, q{%s}],\n", $short // '', $options, $explain // ''; } say '},';