-
Notifications
You must be signed in to change notification settings - Fork 13
/
trace.pl
59 lines (52 loc) · 1.31 KB
/
trace.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
use strict;
use FindBin;
use lib "$FindBin::Bin/lib";
use Getopt::Long;
use Trace;
if ($ARGV[0] eq "create")
{
my $description = "uploaded with osmtools/$0";
my $tags;
my $visibility = "private";
my $correct_options = GetOptions(
"description=s" => \$description,
"tags=s" => \$tags,
"visibility=s" => \$visibility
);
if ($correct_options && (scalar(@ARGV) == 2))
{
my $id = Trace::create($ARGV[1], $description, $tags, $visibility);
print "created a trace with id $id" if defined($id);
exit;
}
}
if (($ARGV[0] eq "get") && (scalar(@ARGV) == 2))
{
my $content = Trace::get($ARGV[1]);
print $content;
exit;
}
if (($ARGV[0] eq "list") && (scalar(@ARGV) == 1))
{
my $content = Trace::list();
print $content;
exit;
}
if (($ARGV[0] eq "delete") && (scalar(@ARGV) == 2))
{
Trace::delete($ARGV[1]);
exit;
}
print <<EOF;
Usage:
$0 create <filename> <options> upload new gpx trace
$0 get <id> load and print trace metadata XML
$0 list load and print metadata of current user's traces
$0 delete <id> delete trace
options:
--description <text>
--tags <text>
--visibility <one of: private, public, trackable, identifiable>
EOF
exit;