#!/usr/bin/perl use strict; use warnings; use 5.010; use YAML qw( LoadFile ); use Term::Choose qw( choose ); binmode(STDOUT, ":encoding(utf8)"); system('chcp 65001 > nul') if ($^O eq 'MSWin32'); my $configF = (shift @ARGV or "launcher_config.yml"); my $config = LoadFile($configF) or die "Can't load config file '$configF'!"; $config->{term_choose_options}->{index} = 1; $config->{reset_shell} //= ($^O eq 'MSWin32' ? 'cls' : 'clear'); go($config->{main}) while 1; ##################################################################### sub go { my $aR = shift; my $items = [ map { ($config->{item_prefix}//'') . [%{$_}]->[0] . ($config->{item_suffix}//'') } @{$aR} ]; my $choice = choose( $items , $config->{term_choose_options} ); my $command = [%{$aR->[$choice]}]->[1]; if (ref $command eq 'ARRAY') { $aR = $command; } elsif (not $command) { return; } elsif ($command eq 'exit') { exit; } else { system($command); system($config->{reset_shell}); } go($aR) }