line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TiddlyWeb::Resting::Getopt; |
2
|
1
|
|
|
1
|
|
1680
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
21
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use base 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
89
|
|
5
|
1
|
|
|
1
|
|
5
|
use TiddlyWeb::Resting::DefaultRester; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
1415
|
use Getopt::Long qw/:config/; |
|
1
|
|
|
|
|
21723
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/get_rester rester_usage/; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
TiddlyWeb::Resting::Getopt - Handle command line rester args |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use TiddlyWeb::Resting::Getopt qw/get_rester/; |
16
|
|
|
|
|
|
|
my $rester = get_rester(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 FUNCTIONS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 get_rester |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Create a new rester from command line args. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_rester { |
31
|
0
|
|
|
0
|
1
|
|
my %opts = @_; |
32
|
0
|
|
|
|
|
|
Getopt::Long::Configure('pass_through'); |
33
|
0
|
|
|
|
|
|
GetOptions( |
34
|
|
|
|
|
|
|
\%opts, |
35
|
|
|
|
|
|
|
'server|s=s', |
36
|
|
|
|
|
|
|
'workspace|w=s', |
37
|
|
|
|
|
|
|
'username|u=s', |
38
|
|
|
|
|
|
|
'password|p=s', |
39
|
|
|
|
|
|
|
'user_cookie=s', |
40
|
|
|
|
|
|
|
'rester-config|c=s', |
41
|
|
|
|
|
|
|
); |
42
|
0
|
|
|
|
|
|
Getopt::Long::Configure('no_pass_through'); |
43
|
0
|
|
|
|
|
|
return TiddlyWeb::Resting::DefaultRester->new(%opts); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 rester_usage |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Return usage text for the arguments accepted by this module. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub rester_usage { |
53
|
0
|
|
|
0
|
1
|
|
my $rc_file = $TiddlyWeb::Resting::DefaultRester::CONFIG_FILE; |
54
|
0
|
|
|
|
|
|
return <
|
55
|
|
|
|
|
|
|
REST API Options: |
56
|
|
|
|
|
|
|
--server TiddyWeb server |
57
|
|
|
|
|
|
|
--username User to login as |
58
|
|
|
|
|
|
|
--password User password |
59
|
|
|
|
|
|
|
--user_cookie tiddlyweb_user cookie to use (supercedes username & password) |
60
|
|
|
|
|
|
|
--workspace Workspace to use |
61
|
|
|
|
|
|
|
--rester-config Config file containing 'key = value' |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Rester Config: |
64
|
|
|
|
|
|
|
Put the above options into $rc_file like this: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
username = some_user\@foobar.com |
67
|
|
|
|
|
|
|
password = your_pass |
68
|
|
|
|
|
|
|
workspace = your_workspace |
69
|
|
|
|
|
|
|
server = https://www.socialtext.net |
70
|
|
|
|
|
|
|
EOT |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Luke Closs, C<< >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
80
|
|
|
|
|
|
|
under the same terms as Perl itself. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |