-# Directory do not exists
-if (file_exists($argv[1]) && !in_array(filetype($argv[1]), array('file','link'))) {
- echo 'File '.$argv[1].' exists and is not a file'."\n";
- exit(1);
+# Init debian
+my @debian = ();
+
+# Init root
+my %root = ();
+tie(%root, 'Tie::IxHash', thumbprint => '/etc/acmepl/thumbprint', certificates => []);
+
+# Init prod
+my $prod = 0;
+
+# Strip and enable prod
+@ARGV = map { if ($_ eq '-p') { $prod = 1; (); } else { $_; } } @ARGV;
+
+# Strip and enable debug
+for (my $i = 0; $i <= $#ARGV; $i++) {
+ # Match redhat types
+ if ($ARGV[$i] =~ /^(?:(\-d|\-\-redhat)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) {
+ if (defined($2)) {
+ push(@redhat, split(',', $2));
+ # Extract next parameter
+ } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) {
+ push(@redhat, split(',', $1));
+ $i++;
+ # Set default
+ } else {
+ push(@redhat, ('example.com'));
+ }
+ # Match debian types
+ } elsif ($ARGV[$i] =~ /^(?:(\-r|\-\-debian)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) {
+ if (defined($2)) {
+ push(@debian, split(',', $2));
+ # Extract next parameter
+ } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) {
+ push(@debian, split(',', $1));
+ $i++;
+ # Set default
+ } else {
+ push(@debian, ('example.com'));
+ }
+ }