Subject: | server_args does not allow boolean flags (w/ patch) |
Greetings!
I was trying to use Ubic::Service::Starman and wanted the server to start w/ --enable-ssl
That flag takes no value and a hash requires a value.
So in server_args:
enable-ssl => 1 resulted in the process looping w/ "Error while loading 1.pm: No such file or directory at (eval 41) line 4."
enable-ssl => "" resulted in the command array having '--enable-ssl', ''.
enable-ssl => undef results in it being left out entirely.
The patch below allows for boolean flags by treating undef values as meaning "I do want this flag but do not want to define a value for this flag".
Please let me know if you have any questions or concerns and I'd be happy to answer them and/or provide a different patch to accomplish the same goal, namely to support flags w/ no value (i.e. boolean flags).
Thanks!
--
Dan Muey
```
--- /home/goservo/perl5/lib/perl5/Ubic/Service/Plack.pm.orig 2016-09-23 12:44:41.422595616 -0500
+++ /home/goservo/perl5/lib/perl5/Ubic/Service/Plack.pm 2016-09-23 12:53:58.526344153 -0500
@@ -65,14 +65,24 @@
my $cmd_key = (length $key == 1) ? '-' : '--';
$cmd_key .= $key;
my $v = $args{$key};
- next unless defined $v;
if (ref $v eq 'ARRAY') {
for my $value (@$v) {
- push @cmd, $cmd_key, $value;
+ if (defined $value) {
+ push @cmd, $cmd_key, $value;
+ }
+ else {
+ push @cmd, $cmd_key;
+ }
}
}
else {
- push @cmd, $cmd_key, $v;
+ if (defined $v) {
+ push @cmd, $cmd_key, $v;
+ }
+ else {
+ push @cmd, $cmd_key
+ }
+
}
}
push @cmd, $self->{app};
```