commit fc2d48d2bb7ae09b42afed03e02d7162eb3c564c from: mischa date: Tue May 30 13:09:57 2023 UTC add option to specify config file with -c commit - 3a3e2afdb0c0705c8f9c2799d984bf68fab82304 commit + fc2d48d2bb7ae09b42afed03e02d7162eb3c564c blob - e4adf64d4f06820c742af79c5d013ff420ce16ce blob + 551a02b1a0696392d9f0709fe7eac42ddf9a50fc --- pushover.pl +++ pushover.pl @@ -27,6 +27,7 @@ GetOptions( "message=s" => \(my $MESSAGE), "title=s" => \(my $TITLE = "Notification"), "priority=i" => \(my $PRIORITY = 0), + "config=s" => \(my $CONFIG), ); my $USAGE = <<"END_USAGE"; @@ -35,10 +36,11 @@ Options: -m | --message text -t | --title text (default: Notification) -p | --priority [0|1] (default: 0) +-c | --config text END_USAGE $MESSAGE || die($USAGE); -my @config_files = grep { -e } ('./_pushover.conf', './.pushover.conf', './pushover.conf', "$ENV{'HOME'}/_pushover.conf", "$ENV{'HOME'}/.pushover.conf", "$ENV{'HOME'}/pushover.conf"); +my @config_files = $CONFIG || grep { -e } ('./_pushover.conf', './.pushover.conf', './pushover.conf', "$ENV{'HOME'}/_pushover.conf", "$ENV{'HOME'}/.pushover.conf", "$ENV{'HOME'}/pushover.conf"); my $config = Config::Tiny->read($config_files[-1], 'utf8'); my $TOKEN = $config->{_}->{token} || die("$USAGE\nError: TOKEN not found.\n"); my $USER = $config->{_}->{user} || die("$USAGE\nError: USER not found.\n");