CSVUtils/csv_sorted_fields.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 35 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« CSVUtils/csv_list_field_names.pm ↑ Summary CSVUtils/csv_sorted_rows.pm »
1 package App::CSVUtils::csv_sorted_fields;
2  
3 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9 2 our $DATE = '2026-07-09'; # DATE
10 2 our $DIST = 'App-CSVUtils'; # DIST
11 2 our $VERSION = '1.038'; # VERSION
12  
13 2 ▶use App::CSVUtils qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
14 gen_csv_util
15 2 );
16 2 ▶use App::CSVUtils::csv_sort_fields;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 gen_csv_util(
19 name => 'csv_sorted_fields',
20 summary => 'Check that CSV fields are sorted',
21 description => <<'MARKDOWN',
22  
23 This utility checks that fields in the CSV are sorted according to specified
24 sorting rule(s). Example `input.csv`:
25  
26 b,c,a
27 1,2,3
28 4,5,6
29  
30 Example check command:
31  
32 % csv-sorted-fields input.csv; # check if the fields are ascibetically sorted
33 ERROR 400: Fields are NOT sorted
34  
35 Example `input2.csv`:
36  
37 c,b,a
38 1,2,3
39 4,5,6
40  
41 % csv-sorted-fields input2.csv -r
42 Fields are sorted
43  
44 See <prog:csv-sort-fields> for details on sorting options.
45  
46 MARKDOWN
47  
48 writes_csv => 0,
49  
50 tags => ['category:checking'],
51  
52 add_args => {
53 # KEEP SYNC WITH csv_sort_fields
54 %App::CSVUtils::argspecs_sort_fields,
55  
56 quiet => {
57 summary => 'If set to true, do not show messages',
58 schema => 'bool*',
59 cmdline_aliases => {q=>{}},
60 },
61 },
62  
63 # KEEP SYNC WITH csv_sort_fields
64 add_args_rels => {
65 choose_one => ['by_examples', 'by_code', 'by_sortsub'],
66 },
67  
68 2 ▶ on_input_header_row => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
69 2 local $main::_CSV_SORTED_FIELDS = 1;
70 2 App::CSVUtils::csv_sort_fields::on_input_header_row(@_);
71 },
72  
73 2 ▶ on_input_data_row => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
74 2 local $main::_CSV_SORTED_FIELDS = 1;
75 2 App::CSVUtils::csv_sort_fields::on_input_data_row(@_);
76 },
77 2 );
78  
79 2 1;
80 # ABSTRACT: Check that CSV fields are sorted
81  
82 __END__
« CSVUtils/csv_list_field_names.pm ↑ Summary CSVUtils/csv_sorted_rows.pm »