| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package GraphQL::Client::CLI; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Implementation of the graphql CLI program |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
73627
|
use warnings; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
568
|
use Encode qw(decode); |
|
|
1
|
|
|
|
|
10544
|
|
|
|
1
|
|
|
|
|
90
|
|
|
8
|
1
|
|
|
1
|
|
773
|
use Getopt::Long 2.39 qw(GetOptionsFromArray); |
|
|
1
|
|
|
|
|
13688
|
|
|
|
1
|
|
|
|
|
33
|
|
|
9
|
1
|
|
|
1
|
|
752
|
use GraphQL::Client; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
35
|
|
|
10
|
1
|
|
|
1
|
|
562
|
use JSON::MaybeXS; |
|
|
1
|
|
|
|
|
5900
|
|
|
|
1
|
|
|
|
|
65
|
|
|
11
|
1
|
|
|
1
|
|
479
|
use Text::ParseWords; |
|
|
1
|
|
|
|
|
1399
|
|
|
|
1
|
|
|
|
|
70
|
|
|
12
|
1
|
|
|
1
|
|
9
|
use namespace::clean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.603'; # VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $JSON = JSON::MaybeXS->new(canonical => 1); |
|
17
|
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
17
|
sub _croak { require Carp; goto &Carp::croak } |
|
|
2
|
|
|
|
|
30
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
|
21
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
|
22
|
0
|
|
|
|
|
0
|
bless {}, $class; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub main { |
|
26
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
27
|
0
|
0
|
|
|
|
0
|
$self = $self->new if !ref $self; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
my $options = eval { $self->_get_options(@_) }; |
|
|
0
|
|
|
|
|
0
|
|
|
30
|
0
|
0
|
|
|
|
0
|
if (my $err = $@) { |
|
31
|
0
|
|
|
|
|
0
|
print STDERR $err; |
|
32
|
0
|
|
|
|
|
0
|
_pod2usage(2); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
0
|
if ($options->{version}) { |
|
36
|
0
|
|
|
|
|
0
|
print "graphql $VERSION\n"; |
|
37
|
0
|
|
|
|
|
0
|
exit 0; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
0
|
0
|
|
|
|
0
|
if ($options->{help}) { |
|
40
|
0
|
|
|
|
|
0
|
_pod2usage(-exitval => 0, -verbose => 99, -sections => [qw(NAME SYNOPSIS OPTIONS)]); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
0
|
0
|
|
|
|
0
|
if ($options->{manual}) { |
|
43
|
0
|
|
|
|
|
0
|
_pod2usage(-exitval => 0, -verbose => 2); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
my $url = $options->{url}; |
|
47
|
0
|
0
|
|
|
|
0
|
if (!$url) { |
|
48
|
0
|
|
|
|
|
0
|
print STDERR "The or --url option argument is required.\n"; |
|
49
|
0
|
|
|
|
|
0
|
_pod2usage(2); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
my $variables = $options->{variables}; |
|
53
|
0
|
|
|
|
|
0
|
my $query = $options->{query}; |
|
54
|
0
|
|
|
|
|
0
|
my $operation_name = $options->{operation_name}; |
|
55
|
0
|
|
|
|
|
0
|
my $unpack = $options->{unpack}; |
|
56
|
0
|
|
|
|
|
0
|
my $outfile = $options->{outfile}; |
|
57
|
0
|
|
|
|
|
0
|
my $format = $options->{format}; |
|
58
|
0
|
|
|
|
|
0
|
my $transport = $options->{transport}; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
my $client = GraphQL::Client->new(url => $url); |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
eval { $client->transport }; |
|
|
0
|
|
|
|
|
0
|
|
|
63
|
0
|
0
|
|
|
|
0
|
if (my $err = $@) { |
|
64
|
0
|
0
|
|
|
|
0
|
warn $err if $ENV{GRAPHQL_CLIENT_DEBUG}; |
|
65
|
0
|
|
|
|
|
0
|
print STDERR "Could not construct a transport for URL: $url\n"; |
|
66
|
0
|
|
|
|
|
0
|
print STDERR "Is this URL correct?\n"; |
|
67
|
0
|
|
|
|
|
0
|
_pod2usage(2); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
0
|
if ($query eq '-') { |
|
71
|
0
|
0
|
|
|
|
0
|
print STDERR "Interactive mode engaged! Waiting for a query on ...\n" |
|
72
|
|
|
|
|
|
|
if -t STDIN; ## no critic (InputOutput::ProhibitInteractiveTest) |
|
73
|
0
|
|
|
|
|
0
|
binmode(STDIN, 'encoding(UTF-8)'); |
|
74
|
0
|
|
|
|
|
0
|
$query = do { local $/; }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
my $resp = $client->execute($query, $variables, $operation_name, $transport); |
|
78
|
0
|
|
|
|
|
0
|
my $err = $resp->{errors}; |
|
79
|
0
|
0
|
|
|
|
0
|
$unpack = 0 if $err; |
|
80
|
0
|
0
|
|
|
|
0
|
my $data = $unpack ? $resp->{data} : $resp; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
0
|
if ($outfile) { |
|
83
|
0
|
0
|
|
|
|
0
|
open(my $out, '>', $outfile) or die "Open $outfile failed: $!"; |
|
84
|
0
|
|
|
|
|
0
|
*STDOUT = $out; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
binmode(STDOUT, 'encoding(UTF-8)'); |
|
88
|
0
|
|
|
|
|
0
|
_print_data($data, $format); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
0
|
0
|
|
|
0
|
exit($unpack && $err ? 1 : 0); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _get_options { |
|
94
|
3
|
|
|
3
|
|
2802
|
my $self = shift; |
|
95
|
3
|
|
|
|
|
10
|
my @args = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
3
|
|
50
|
|
|
24
|
unshift @args, shellwords($ENV{GRAPHQL_CLIENT_OPTIONS} || ''); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# assume UTF-8 args if non-ASCII |
|
100
|
1
|
50
|
|
1
|
|
1651
|
@args = map { decode('UTF-8', $_) } @args if grep { /\P{ASCII}/ } @args; |
|
|
1
|
|
|
|
|
15
|
|
|
|
1
|
|
|
|
|
16
|
|
|
|
3
|
|
|
|
|
72
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
9
|
|
|
|
|
31
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
3
|
|
|
|
|
11
|
my %options = ( |
|
103
|
|
|
|
|
|
|
format => 'json:pretty', |
|
104
|
|
|
|
|
|
|
unpack => 0, |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
GetOptionsFromArray(\@args, |
|
108
|
|
|
|
|
|
|
'version' => \$options{version}, |
|
109
|
|
|
|
|
|
|
'help|h|?' => \$options{help}, |
|
110
|
|
|
|
|
|
|
'manual|man' => \$options{manual}, |
|
111
|
|
|
|
|
|
|
'url|u=s' => \$options{url}, |
|
112
|
|
|
|
|
|
|
'query|mutation=s' => \$options{query}, |
|
113
|
|
|
|
|
|
|
'variables|vars|V=s' => \$options{variables}, |
|
114
|
|
|
|
|
|
|
'variable|var|d=s%' => \$options{variables}, |
|
115
|
|
|
|
|
|
|
'operation-name|n=s' => \$options{operation_name}, |
|
116
|
|
|
|
|
|
|
'transport|t=s%' => \$options{transport}, |
|
117
|
|
|
|
|
|
|
'format|f=s' => \$options{format}, |
|
118
|
|
|
|
|
|
|
'unpack!' => \$options{unpack}, |
|
119
|
|
|
|
|
|
|
'output|o=s' => \$options{outfile}, |
|
120
|
3
|
50
|
|
|
|
31
|
) or _pod2usage(2); |
|
121
|
|
|
|
|
|
|
|
|
122
|
3
|
100
|
|
|
|
3226
|
$options{url} = shift @args if !$options{url}; |
|
123
|
3
|
100
|
|
|
|
12
|
$options{query} = shift @args if !$options{query}; |
|
124
|
|
|
|
|
|
|
|
|
125
|
3
|
|
50
|
|
|
8
|
$options{query} ||= '-'; |
|
126
|
|
|
|
|
|
|
|
|
127
|
3
|
|
|
|
|
6
|
my $transport = eval { _expand_vars($options{transport}) }; |
|
|
3
|
|
|
|
|
11
|
|
|
128
|
3
|
50
|
|
|
|
7
|
die "Two or more --transport keys are incompatible.\n" if $@; |
|
129
|
|
|
|
|
|
|
|
|
130
|
3
|
50
|
|
|
|
12
|
if (ref $options{variables}) { |
|
|
|
50
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
0
|
$options{variables} = eval { _expand_vars($options{variables}) }; |
|
|
0
|
|
|
|
|
0
|
|
|
132
|
0
|
0
|
|
|
|
0
|
die "Two or more --variable keys are incompatible.\n" if $@; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
elsif ($options{variables}) { |
|
135
|
0
|
|
|
|
|
0
|
$options{variables} = eval { $JSON->decode($options{variables}) }; |
|
|
0
|
|
|
|
|
0
|
|
|
136
|
0
|
0
|
|
|
|
0
|
die "The --variables JSON does not parse.\n" if $@; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
3
|
|
|
|
|
12
|
return \%options; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub _stringify { |
|
143
|
0
|
|
|
0
|
|
0
|
my ($item) = @_; |
|
144
|
0
|
0
|
|
|
|
0
|
if (ref($item) eq 'ARRAY') { |
|
145
|
0
|
|
0
|
|
|
0
|
my $first = @$item && $item->[0]; |
|
146
|
0
|
0
|
|
|
|
0
|
return join(',', @$item) if !ref($first); |
|
147
|
0
|
|
|
|
|
0
|
return join(',', map { $JSON->encode($_) } @$item); |
|
|
0
|
|
|
|
|
0
|
|
|
148
|
|
|
|
|
|
|
} |
|
149
|
0
|
0
|
|
|
|
0
|
return $JSON->encode($item) if ref($item) eq 'HASH'; |
|
150
|
0
|
|
|
|
|
0
|
return $item; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _print_data { |
|
154
|
0
|
|
|
0
|
|
0
|
my ($data, $format) = @_; |
|
155
|
0
|
|
0
|
|
|
0
|
$format = lc($format || 'json:pretty'); |
|
156
|
0
|
0
|
0
|
|
|
0
|
if ($format eq 'json' || $format eq 'json:pretty') { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
0
|
my %opts = (allow_nonref => 1, canonical => 1); |
|
158
|
0
|
0
|
|
|
|
0
|
$opts{pretty} = 1 if $format eq 'json:pretty'; |
|
159
|
0
|
|
|
|
|
0
|
print JSON::MaybeXS->new(%opts)->encode($data); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
elsif ($format eq 'yaml') { |
|
162
|
0
|
0
|
|
|
|
0
|
eval { require YAML } or die "Missing dependency: YAML\n"; |
|
|
0
|
|
|
|
|
0
|
|
|
163
|
0
|
|
|
|
|
0
|
print YAML::Dump($data); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
elsif ($format eq 'csv' || $format eq 'tsv' || $format eq 'table') { |
|
166
|
0
|
0
|
|
|
|
0
|
my $sep = $format eq 'tsv' ? "\t" : ','; |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
0
|
my $unpacked = $data; |
|
169
|
|
|
|
|
|
|
# $unpacked = $data->{data} if !$unpack && !$err; |
|
170
|
0
|
0
|
0
|
|
|
0
|
$unpacked = $data->{data} if $data && $data->{data}; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# check the response to see if it can be formatted |
|
173
|
0
|
|
|
|
|
0
|
my @columns; |
|
174
|
0
|
|
|
|
|
0
|
my $rows = []; |
|
175
|
0
|
0
|
|
|
|
0
|
if (keys %$unpacked == 1) { |
|
176
|
0
|
|
|
|
|
0
|
my ($val) = values %$unpacked; |
|
177
|
0
|
0
|
|
|
|
0
|
if (ref $val eq 'ARRAY') { |
|
178
|
0
|
|
|
|
|
0
|
my $first = $val->[0]; |
|
179
|
0
|
0
|
0
|
|
|
0
|
if ($first && ref $first eq 'HASH') { |
|
|
|
0
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
0
|
@columns = sort keys %$first; |
|
181
|
|
|
|
|
|
|
$rows = [ |
|
182
|
0
|
|
|
|
|
0
|
map { [map { _stringify($_) } @{$_}{@columns}] } @$val |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
183
|
|
|
|
|
|
|
]; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
elsif ($first) { |
|
186
|
0
|
|
|
|
|
0
|
@columns = keys %$unpacked; |
|
187
|
0
|
|
|
|
|
0
|
$rows = [map { [map { _stringify($_) } $_] } @$val]; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
0
|
|
|
|
0
|
if (@columns) { |
|
193
|
0
|
0
|
|
|
|
0
|
if ($format eq 'table') { |
|
194
|
0
|
0
|
|
|
|
0
|
eval { require Text::Table::Any } or die "Missing dependency: Text::Table::Any\n"; |
|
|
0
|
|
|
|
|
0
|
|
|
195
|
|
|
|
|
|
|
my $table = Text::Table::Any::table( |
|
196
|
|
|
|
|
|
|
header_row => 1, |
|
197
|
|
|
|
|
|
|
rows => [[@columns], @$rows], |
|
198
|
|
|
|
|
|
|
backend => $ENV{PERL_TEXT_TABLE}, |
|
199
|
0
|
|
|
|
|
0
|
); |
|
200
|
0
|
|
|
|
|
0
|
print $table; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
else { |
|
203
|
0
|
0
|
|
|
|
0
|
eval { require Text::CSV } or die "Missing dependency: Text::CSV\n"; |
|
|
0
|
|
|
|
|
0
|
|
|
204
|
0
|
|
|
|
|
0
|
my $csv = Text::CSV->new({binary => 1, sep => $sep, eol => $/}); |
|
205
|
0
|
|
|
|
|
0
|
$csv->print(*STDOUT, [@columns]); |
|
206
|
0
|
|
|
|
|
0
|
for my $row (@$rows) { |
|
207
|
0
|
|
|
|
|
0
|
$csv->print(*STDOUT, $row); |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
else { |
|
212
|
0
|
|
|
|
|
0
|
_print_data($data); |
|
213
|
0
|
|
|
|
|
0
|
print STDERR sprintf("Error: Response could not be formatted as %s.\n", uc($format)); |
|
214
|
0
|
|
|
|
|
0
|
exit 3; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
elsif ($format eq 'perl') { |
|
218
|
0
|
0
|
|
|
|
0
|
eval { require Data::Dumper } or die "Missing dependency: Data::Dumper\n"; |
|
|
0
|
|
|
|
|
0
|
|
|
219
|
0
|
|
|
|
|
0
|
print Data::Dumper::Dumper($data); |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
else { |
|
222
|
0
|
|
|
|
|
0
|
print STDERR "Error: Format not supported: $format\n"; |
|
223
|
0
|
|
|
|
|
0
|
_print_data($data); |
|
224
|
0
|
|
|
|
|
0
|
exit 3; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _parse_path { |
|
229
|
8
|
|
|
8
|
|
11
|
my $path = shift; |
|
230
|
|
|
|
|
|
|
|
|
231
|
8
|
|
|
|
|
14
|
my @path; |
|
232
|
|
|
|
|
|
|
|
|
233
|
8
|
|
|
|
|
35
|
my @segments = map { split(/\./, $_) } split(/(\[[^\.\]]+\])\.?/, $path); |
|
|
15
|
|
|
|
|
38
|
|
|
234
|
8
|
|
|
|
|
19
|
for my $segment (@segments) { |
|
235
|
19
|
100
|
|
|
|
47
|
if ($segment =~ /\[([^\.\]]+)\]/) { |
|
236
|
4
|
50
|
|
|
|
12
|
$path[-1]{type} = 'ARRAY' if @path; |
|
237
|
4
|
|
|
|
|
14
|
push @path, { |
|
238
|
|
|
|
|
|
|
name => $1, |
|
239
|
|
|
|
|
|
|
index => 1, |
|
240
|
|
|
|
|
|
|
}; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
else { |
|
243
|
15
|
100
|
|
|
|
30
|
$path[-1]{type} = 'HASH' if @path; |
|
244
|
15
|
|
|
|
|
38
|
push @path, { |
|
245
|
|
|
|
|
|
|
name => $segment, |
|
246
|
|
|
|
|
|
|
}; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
8
|
|
|
|
|
21
|
return \@path; |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub _expand_vars { |
|
254
|
6
|
|
|
6
|
|
5558
|
my $vars = shift; |
|
255
|
|
|
|
|
|
|
|
|
256
|
6
|
|
|
|
|
13
|
my $root = {}; |
|
257
|
|
|
|
|
|
|
|
|
258
|
6
|
|
|
|
|
31
|
while (my ($key, $value) = each %$vars) { |
|
259
|
8
|
|
|
|
|
19
|
my $parsed_path = _parse_path($key); |
|
260
|
|
|
|
|
|
|
|
|
261
|
8
|
|
|
|
|
12
|
my $curr = $root; |
|
262
|
8
|
|
|
|
|
14
|
for my $segment (@$parsed_path) { |
|
263
|
18
|
|
|
|
|
29
|
my $name = $segment->{name}; |
|
264
|
18
|
|
100
|
|
|
46
|
my $type = $segment->{type} || ''; |
|
265
|
18
|
100
|
|
|
|
41
|
my $next = $type eq 'HASH' ? {} : $type eq 'ARRAY' ? [] : $value; |
|
|
|
100
|
|
|
|
|
|
|
266
|
18
|
100
|
|
|
|
49
|
if (ref $curr eq 'HASH') { |
|
|
|
50
|
|
|
|
|
|
|
267
|
15
|
50
|
|
|
|
31
|
_croak 'Conflicting keys' if $segment->{index}; |
|
268
|
15
|
100
|
|
|
|
25
|
if (defined $curr->{$name}) { |
|
269
|
3
|
100
|
|
|
|
14
|
_croak 'Conflicting keys' if $type ne ref $curr->{$name}; |
|
270
|
1
|
|
|
|
|
3
|
$next = $curr->{$name}; |
|
271
|
|
|
|
|
|
|
} |
|
272
|
|
|
|
|
|
|
else { |
|
273
|
12
|
|
|
|
|
25
|
$curr->{$name} = $next; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
elsif (ref $curr eq 'ARRAY') { |
|
277
|
3
|
50
|
|
|
|
8
|
_croak 'Conflicting keys' if !$segment->{index}; |
|
278
|
3
|
50
|
|
|
|
9
|
if (defined $curr->[$name]) { |
|
279
|
0
|
0
|
|
|
|
0
|
_croak 'Conflicting keys' if $type ne ref $curr->[$name]; |
|
280
|
0
|
|
|
|
|
0
|
$next = $curr->[$name]; |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
else { |
|
283
|
3
|
|
|
|
|
6
|
$curr->[$name] = $next; |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
} |
|
286
|
|
|
|
|
|
|
else { |
|
287
|
0
|
|
|
|
|
0
|
_croak 'Conflicting keys'; |
|
288
|
|
|
|
|
|
|
} |
|
289
|
16
|
|
|
|
|
47
|
$curr = $next; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|
|
293
|
4
|
|
|
|
|
14
|
return $root; |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub _pod2usage { |
|
297
|
0
|
|
|
0
|
|
|
eval { require Pod::Usage }; |
|
|
0
|
|
|
|
|
|
|
|
298
|
0
|
0
|
|
|
|
|
if ($@) { |
|
299
|
0
|
0
|
|
|
|
|
my $ref = $VERSION eq '999.999' ? 'master' : "v$VERSION"; |
|
300
|
|
|
|
|
|
|
my $exit = (@_ == 1 && $_[0] =~ /^\d+$/ && $_[0]) // |
|
301
|
0
|
|
0
|
|
|
|
(@_ % 2 == 0 && {@_}->{'-exitval'}) // 2; |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
302
|
0
|
|
|
|
|
|
print STDERR <
|
|
303
|
|
|
|
|
|
|
Online documentation is available at: |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
https://github.com/chazmcgarvey/graphql-client/blob/$ref/README.md |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Tip: To enable inline documentation, install the Pod::Usage module. |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
END |
|
310
|
0
|
|
|
|
|
|
exit $exit; |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
else { |
|
313
|
0
|
|
|
|
|
|
goto &Pod::Usage::pod2usage; |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
1; |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
__END__ |