has $opt :reader;
has $db;
has $db_generation;
- has $mpd;
+ has $mpd :reader;
use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf';
$opt->parse_command_line;
unless ($opt->dump_config) {
- $mpd = Net::Async::MPD->new(
- host => $opt->mpd_host,
- port => $opt->mpd_port,
- auto_connect => 1,
- );
+ my %conn = ( auto_connect => 1 );
+ $conn{host} = $opt->mpd_host if $opt->mpd_host;
+ $conn{port} = $opt->mpd_port if $opt->mpd_port;
+
+ $mpd = Net::Async::MPD->new(%conn);
$self->connect_db;
$self->update_db unless $self->opt->skip_db_update;