From e8fdedb133561c65be4adcb3308b58fdd5d9a630 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 6 Sep 2019 20:57:42 +0200 Subject: [PATCH] cli: mkclioptions core program presets Input group names for selected entries from debian coreutils, bsdmainutils, git subcommands, others. --- tools/mkclioptions | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/tools/mkclioptions b/tools/mkclioptions index 74cdcf6..020f025 100755 --- a/tools/mkclioptions +++ b/tools/mkclioptions @@ -7,24 +7,56 @@ 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 '},'; -- 2.30.0