add sections to config file, supporting multiple pushover apps in the same config file
This commit is contained in:
parent
fc2d48d2bb
commit
de9fb1cd47
@ -1,2 +1,8 @@
|
||||
token = TOKENTOKEN
|
||||
user = USERUSER
|
||||
[pushover application]
|
||||
token = TOKENTOKEN
|
||||
user = USERUSER
|
||||
[application]
|
||||
token = TOKENTOKEN
|
||||
user = USERUSER
|
||||
|
16
pushover.pl
16
pushover.pl
@ -28,22 +28,24 @@ GetOptions(
|
||||
"title=s" => \(my $TITLE = "Notification"),
|
||||
"priority=i" => \(my $PRIORITY = 0),
|
||||
"config=s" => \(my $CONFIG),
|
||||
"application=s" => \(my $APPLICATION = '_'),
|
||||
);
|
||||
|
||||
my $USAGE = <<"END_USAGE";
|
||||
Usage: $0 [-m message] [-t title] [-p priority]
|
||||
Usage: $0 -m message [-t title] [-p priority] [-a application] [-c config]
|
||||
Options:
|
||||
-m | --message text
|
||||
-t | --title text (default: Notification)
|
||||
-p | --priority [0|1] (default: 0)
|
||||
-c | --config text
|
||||
-m | --message text
|
||||
-t | --title text | (default: Notification)
|
||||
-p | --priority [0|1] (default: 0)
|
||||
-a | --application text (default: root property of config)
|
||||
-c | --config text (no default)
|
||||
END_USAGE
|
||||
|
||||
$MESSAGE || die($USAGE);
|
||||
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");
|
||||
my $TOKEN = $config->{$APPLICATION}->{token} || die("$USAGE\nError: TOKEN not found.\n");
|
||||
my $USER = $config->{$APPLICATION}->{user} || die("$USAGE\nError: USER not found.\n");
|
||||
|
||||
my $http = HTTP::Tiny->new;
|
||||
my %HEADERS = ("Content-Type" => "application/json");
|
||||
|
Loading…
Reference in New Issue
Block a user