|
5 | 5 |
|
6 | 6 | use strict; |
7 | 7 | use warnings; |
8 | | -use Getopt::Long qw(:config no_auto_abbrev no_ignore_case); |
9 | 8 | use Time::HiRes (); |
10 | 9 | use POSIX (); |
11 | 10 |
|
|
23 | 22 | my $log_fname = "$work_dir/app.log"; # global log |
24 | 23 | my $path_pfx = "$work_dir/$sess_code"; |
25 | 24 |
|
26 | | -Getopt::Long::GetOptions( |
27 | | - 'aur' => \(my $use_aur), |
28 | | - 'help|h' => \(my $show_help), |
29 | | -); |
| 25 | +my %cmd_args = (); |
| 26 | +while (my $arg = shift(@ARGV)) { |
| 27 | + if ($arg eq '-h' || $arg eq '--help') { $cmd_args{help} = 1; } |
| 28 | + elsif ($arg eq '--aur') { $cmd_args{aur} = 1; } |
| 29 | +} |
30 | 30 |
|
31 | | -# die("Install 'yay' to use AUR feature\n") if $use_aur && !$yayx; |
32 | 31 | # TODO: new information report dialog - package full dependency tree |
33 | 32 |
|
34 | 33 | my $shutdown_hooks = []; |
|
48 | 47 | my $pac_inst_states = [ |
49 | 48 | { code => 'E', label => 'Explicitly Installed', short => 'explicit' }, |
50 | 49 | { code => 'D', label => 'Installed as Dependency', short => 'as dep' }, # was 'I' |
51 | | - { code => 'N', label => 'Not Installed', short => 'not inst' } |
| 50 | + { code => 'N', label => 'Not Installed', short => 'not inst' }, |
| 51 | + { code => '*', label => 'All', short => '' } |
52 | 52 | ]; |
53 | 53 |
|
54 | 54 | my $outdated_states = [ |
|
153 | 153 | # prepare key map |
154 | 154 | my $tmux_key_map = {map {$_->{key} => $_} @$tmux_key_list}; |
155 | 155 |
|
156 | | -$show_help && do{ print(help()); exit(0); }; |
| 156 | +$cmd_args{help} && do{ print(help()); exit(0); }; |
157 | 157 | tmux_start($tmux); |
158 | 158 |
|
159 | 159 | while (my $msg = pacbro_next_input_cmd($tmux)) { |
@@ -196,7 +196,7 @@ sub tmux_start { |
196 | 196 | my $binds = "--bind enter:'$sel_action' --bind double-click:'$sel_action'"; |
197 | 197 | $binds .= " --bind left-click:'$sel_action'"; |
198 | 198 | $binds .= " --bind focus:'execute-silent(echo PACFOCUS {} >> $cmd_in)'"; |
199 | | - # $binds .= " --bind focus:'$sel_action'" if !$use_aur; # do not auto-load package info |
| 199 | + # $binds .= " --bind focus:'$sel_action'" if !$cmd_args{aur}; # do not auto-load package info |
200 | 200 | $binds .= " --bind 'ctrl-alt-r:reload(cat $main_file)'"; |
201 | 201 | $binds .= " --bind 'load:first'"; |
202 | 202 | $binds .= " --bind 'start:unbind(ctrl-c,ctrl-g,ctrl-q,esc)'"; # do not allow exiting keys |
@@ -402,7 +402,7 @@ sub package_sel { |
402 | 402 |
|
403 | 403 | if (!($_ = $tmux->{pac}) || $_->{name} ne $pac->{name}) { # if package is different |
404 | 404 | write_file("$tmux->{pans}->{info}->{file}", $pac->{info_text} // ''); |
405 | | - $tmux->{comm}->("send-keys -t $tmux->{pans}->{info}->{id} q g"); |
| 405 | + $tmux->{comm}->("send-keys -t $tmux->{pans}->{info}->{id} g R"); |
406 | 406 | } |
407 | 407 | $tmux->{pac} = $pac; |
408 | 408 | my $pac_det_lists = pac_deps_lists_get_or_load($pac, $tmux->{db}->{pac_map}); # { list_name => multiline_text } |
@@ -493,7 +493,7 @@ sub pac_db_load_full { # load/pull full package list & package details map |
493 | 493 |
|
494 | 494 | report(iso_tstmp_now() . " will load packages' metadata now"); |
495 | 495 |
|
496 | | - my $pac_list_exe = ($use_aur ? "(curl -sL https://aur.archlinux.org/packages.gz | gunzip | sed -e 's/^/aur /'; pacman -Sl)" : "pacman -Sl") . ' | sort -k 2.1'; |
| 496 | + my $pac_list_exe = ($cmd_args{aur} ? "(curl -sL https://aur.archlinux.org/packages.gz | gunzip | sed -e 's/^/aur /'; pacman -Sl)" : "pacman -Sl") . ' | sort -k 2.1'; |
497 | 497 | my ($pac_list_file, $pac_inst_file, $pac_sync_file, $pac_files_file) = ("$work_dir/db_pac_list", "$work_dir/db_pac_inst", "$work_dir/db_pac_sync", "$work_dir/db_pac_files"); |
498 | 498 |
|
499 | 499 | system(<<~"CMD"); |
@@ -932,14 +932,16 @@ sub repo_filter { |
932 | 932 | sub inst_filter { |
933 | 933 | my ($tmux, $menu, $item_list) = @_; |
934 | 934 | !@$item_list && return; # exited via Esc |
935 | | - $item_list = [] if scalar(@$item_list) == scalar(@$pac_inst_states); # ALL - no filter |
| 935 | + $item_list = [] if scalar(@$item_list) >= (scalar(@$pac_inst_states) - 1); # ALL - no filter |
936 | 936 |
|
937 | 937 | my $code_by_lab = ($::{pac_inst_cd_by_lab} //= {map {$_->{label} => $_->{code}} @$pac_inst_states}); |
938 | 938 | my $codes = join('', sort grep { $_ } map {$code_by_lab->{$_}} @$item_list); |
| 939 | + ($item_list, $codes) = ([], '') if index($codes, '*') > -1; |
| 940 | + $menu->{chosen} = $item_list; |
| 941 | + |
939 | 942 | $codes eq ($tmux->{flt}->{inst} // '') && return; # not changed |
940 | 943 | $tmux->{flt}->{inst} = $codes; |
941 | 944 |
|
942 | | - $menu->{chosen} = $item_list; |
943 | 945 | pac_list_load($tmux); |
944 | 946 | tmux_status_bar_update($tmux); |
945 | 947 | } |
|
0 commit comments