From d0e398f974a7fd28f6b3889083b406d4bd8a817f Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Wed, 25 Nov 2020 19:36:50 -0600 Subject: [PATCH] kml.pl: Stub remove, set and usage modes --- kml.pl | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/kml.pl b/kml.pl index 70a06b4..5551892 100755 --- a/kml.pl +++ b/kml.pl @@ -7,17 +7,42 @@ use warnings; use XML::LibXML; use URI::Escape; -my ($name, $coordinates) = @ARGV; - my $filename = 'ours.kml'; my $dom = XML::LibXML->load_xml(location => $filename, no_blanks => 1); my $xpc = XML::LibXML::XPathContext->new($dom); $xpc->registerNs('k', "http://earth.google.com/kml/2.2"); -append_placemark($name, $coordinates, uri_escape($name)); - -print $dom->toString(1); +my $mode = shift; +if ($mode eq 'add') +{ + my ($name, $coordinates) = @ARGV; + unless (defined($name) && defined($coordinates)) + { + say "Not enough args for add operation"; + USAGE(1); + } + append_placemark($name, $coordinates, uri_escape($name)); + print $dom->toString(1); +} +elsif ($mode eq 'remove') +{ + say "Remove mode"; +} +elsif ($mode eq 'set') +{ + say "Set mode"; +} +else +{ + USAGE(1); +} +sub USAGE +{ + my $code = shift; + say "USAGE: "; + exit($code); +} sub add_empty_child { my $node = shift;