commit - 3baf40e13bf91a7ee8b1257ec20ebec4333a1a6e
commit + 65a731a71b96920ca93fab12e8187ce0287104a4
blob - c5a7e893fe36952c25c52dee838729307aabe363
blob + 64d28263337da0d5a4d88b6863cab8354ba6927f
--- tibber.pl
+++ tibber.pl
use strict;
use warnings;
use autodie;
+use Config::Tiny;
use Getopt::Long;
use HTTP::Tiny;
use JSON::PP;
use Data::Dumper;
-my $TOKEN = "";
+GetOptions(
+ "config=s" => \(my $CONFIG),
+);
+my $USAGE = <<"END_USAGE";
+Usage: $0 [-c config]
+Options:
+-c | --config text (no default)
+END_USAGE
+
+my @config_files = $CONFIG || grep { -e } ('./_tibber.conf', './.tibber.conf', './tibber.conf', "$ENV{'HOME'}/_tibber.conf", "$ENV{'HOME'}/.tibber.conf", "$ENV{'HOME'}/tibber.conf");
+my $config = Config::Tiny->read($config_files[-1], 'utf8');
+my $TOKEN = $config->{$APPLICATION}->{token} || die("$USAGE\nError: TOKEN not found.\n");
+
my $http = HTTP::Tiny->new;
my %HEADERS = ("Content-Type" => "application/json", "Authorization" => "Bearer $TOKEN");
my $uri = "https://api.tibber.com/v1-beta/gql";
blob - /dev/null
blob + bdbf5110f1b3d851353dbff80a6b5de9e2004f7f (mode 644)
--- /dev/null
+++ .gitignore
+tibber.conf
blob - /dev/null
blob + 5a4d97acef05e658da6561a7d92a91d8e8f61304 (mode 644)
--- /dev/null
+++ tibber.conf-sample
+token = TOKENTOKEN