-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoption.hpp
1199 lines (1144 loc) · 34.4 KB
/
option.hpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include "gg_error.hpp"
#include "output.hpp"
#include "types.hpp"
#include <lexertl/memory_file.hpp>
#include <wildcardtl/wildcard.hpp>
#ifdef _WIN32
#include <consoleapi.h>
#include <minwindef.h>
#include <processenv.h>
#include <WinBase.h>
#include <winnt.h>
#endif
#include <charconv>
#include <cstdlib>
#include <cstdio>
#include <filesystem>
#include <format>
#include <iosfwd>
#include <iostream>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
extern unsigned int g_flags;
extern options g_options;
extern void add_pattern(const char* param, std::vector<config>& configs);
extern bool is_windows();
extern void parse_condition(const char* str);
extern void show_help();
extern void show_usage(const std::string& msg = std::string());
extern std::vector<std::string_view> split(const char* str, const char c);
extern std::string unescape(const std::string_view& vw);
struct option
{
enum class type
{
regexp,
misc,
output,
context,
gram_grep
};
type _type;
const char _short;
const char* _long;
const char* _param;
const char* _help;
void (*_func)(int& i, const bool longp,
const char* const argv[], std::string_view param,
std::vector<config>& configs);
};
void check_pattern_set()
{
if (g_options._pattern_type != pattern_type::none)
throw gg_error("conflicting matchers specified");
}
void colour(int&, const bool, const char* const [], std::string_view value,
std::vector<config>&)
{
if (!value.empty() && value != "always" && value != "auto" && value != "never")
{
show_help();
exit(2);
}
if (value == "never")
g_options._colour = false;
else
{
#ifdef _WIN32
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwMode = 0;
::GetConsoleMode(hOutput, &dwMode);
if (value.empty() || value == "auto")
g_options._colour = (dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
else
{
::SetConsoleMode(hOutput, dwMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
g_options._colour = true;
}
// No need to close hOutput
#else
g_options._colour = true;
#endif
}
}
void validate_value(int& i, const char* const argv[],
const bool longp, std::string_view& value)
{
if (!longp)
{
++i;
value = argv[i];
}
}
void add_pathname(const char* first, const char* second, wildcards& wcs)
{
const std::string pathname(*first == '!' ? first + 1 : first, second);
if (*first == '!')
{
// Not using emplace_back() for compatibility with Macintosh
wcs._negative.push_back({ wildcardtl::wildcard
{ pathname, is_windows() },
// If pathname does not include a wildcard
// store it as a plain string for error reporting.
pathname.find_first_of("*?[") == std::string::npos ?
pathname :
std::string() });
}
else
{
// Not using emplace_back() for compatibility with Macintosh
wcs._positive.push_back({ wildcardtl::wildcard
{ pathname, is_windows() },
// If pathname does not include a wildcard
// store it as a plain string for error reporting.
pathname.find_first_of("*?[") == std::string::npos ?
pathname :
std::string() });
}
}
const option g_option[]
{
{
option::type::regexp,
'E',
"extended-regexp",
nullptr,
"PATTERNS are extended regular expressions",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
check_pattern_set();
g_options._pattern_type = pattern_type::extended;
}
},
{
option::type::regexp,
'F',
"fixed-strings",
nullptr,
"PATTERN is a string",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
check_pattern_set();
g_options._pattern_type = pattern_type::fixed;
}
},
{
option::type::regexp,
'G',
"basic-regexp",
nullptr,
"PATTERNS are basic regular expressions",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
check_pattern_set();
g_options._pattern_type = pattern_type::basic;
}
},
{
option::type::regexp,
'P',
"perl-regexp",
nullptr,
"PATTERN is a Perl regular expression",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
check_pattern_set();
g_options._pattern_type = pattern_type::perl;
}
},
{
option::type::regexp,
'e',
"regexp",
"PATTERNS",
"use PATTERNS for matching",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>& configs)
{
check_pattern_set();
validate_value(i, argv, longp, value);
g_options._pattern_type = pattern_type::basic;
// We know that the string is zero terminated
add_pattern(value.data(), configs);
}
},
{
option::type::regexp,
'f',
"file",
"FILE",
"take PATTERNS from FILE",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>& configs)
{
check_pattern_set();
validate_value(i, argv, longp, value);
// We know that the string is zero terminated
lexertl::memory_file mf(value.data());
if (!mf.data())
throw gg_error(std::format("Unable to open {}", value));
const char* first = mf.data();
const char* second = first + mf.size();
std::string regex;
do
{
auto end = std::find_if(first, second,
[](const char c)
{
return c == '\r' || c == '\n';
});
if (!regex.empty())
regex += '\n';
regex.append(first, end);
end = std::find_if(end, second,
[](const char c)
{
return c != '\r' && c != '\n';
});
first = end;
} while (first != second);
g_options._pattern_type = pattern_type::basic;
add_pattern(regex.c_str(), configs);
}
},
{
option::type::regexp,
'i',
"ignore-case",
nullptr,
"ignore case distinctions in patterns and data",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
// Use the lexertl enum operator
using namespace lexertl;
g_flags |= *config_flags::icase;
}
},
{
option::type::regexp,
'\0',
"no-ignore-case",
nullptr,
"do not ignore case distinctions (default)",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
// Use the lexertl enum operator
using namespace lexertl;
g_flags &= *config_flags::icase;
}
},
{
option::type::regexp,
'w',
"word-regexp",
nullptr,
"match only whole words",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
// Use the lexertl enum operator
using namespace lexertl;
g_flags |= *config_flags::whole_word;
}
},
{
option::type::regexp,
'x',
"line-regexp",
nullptr,
"match only whole lines",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
// Use the lexertl enum operator
using namespace lexertl;
g_flags |= *config_flags::bol_eol;
}
},
{
option::type::misc,
's',
"no-messages",
nullptr,
"suppress error messages",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._no_messages = true;
}
},
{
option::type::misc,
'v',
"invert-match",
nullptr,
"select non-matching text",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
// Use the lexertl enum operator
using namespace lexertl;
g_flags |= *config_flags::negate;
}
},
{
option::type::misc,
'V',
"version",
nullptr,
"display version information and exit",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._show_version = true;
}
},
{
option::type::misc,
'\0',
"help",
nullptr,
"display this help text and exit",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
show_help();
exit(0);
}
},
{
option::type::output,
'm',
"max-count",
"NUM",
"stop after NUM selected lines",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>&)
{
std::stringstream ss;
validate_value(i, argv, longp, value);
ss << value;
ss >> g_options._max_count;
}
},
{
option::type::output,
'b',
"byte-offset",
nullptr,
"print the byte offset with output lines",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._byte_offset = true;
}
},
{
option::type::output,
'n',
"line-number",
nullptr,
"print line number with output lines",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._line_numbers = line_numbers::yes;
}
},
{
option::type::output,
'\0',
"line-buffered",
nullptr,
"flush output on every line",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._line_buffered = true;
}
},
{
option::type::output,
'H',
"with-filename",
nullptr,
"print file name with output lines",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._show_filename = show_filename::yes;
}
},
{
option::type::output,
'h',
"no-filename",
nullptr,
"suppress the file name prefix on output",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._show_filename = show_filename::no;
}
},
{
option::type::output,
'\0',
"label",
"LABEL",
"use LABEL as the standard input file name prefix",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
g_options._label = value;
}
},
{
option::type::output,
'o',
"only-matching",
nullptr,
"show only nonempty parts of lines that match",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._only_matching = true;
}
},
{
option::type::output,
'q',
"quiet,silent",
nullptr,
"suppress all normal output",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._quiet = true;
}
},
{
option::type::output,
'\0',
"binary-files",
"TYPE",
"assume that binary files are TYPE;\n"
"TYPE is 'binary', 'text', or 'without-match'",
[](int&, const bool, const char* const [], std::string_view value,
std::vector<config>&)
{
if (value == "binary")
g_options._binary_files = binary_files::binary;
else if (value == "text")
g_options._binary_files = binary_files::text;
else if (value == "without-match")
g_options._binary_files = binary_files::without_match;
else
throw gg_error("unknown binary-files type");
}
},
{
option::type::output,
'a',
"text",
nullptr,
"equivalent to --binary-files=text",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._binary_files = binary_files::text;
}
},
{
option::type::output,
'I',
nullptr,
nullptr,
"equivalent to --binary-files=without-match",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._binary_files = binary_files::without_match;
}
},
{
option::type::output,
'd',
"directories",
"ACTION",
"how to handle directories;\n"
"ACTION is 'read', 'recurse', or 'skip'",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>&)
{
validate_value(i, argv, longp, value);
if (value == "read")
g_options._directories = directories::read;
else if (value == "recurse")
g_options._directories = directories::recurse;
else if (value == "skip")
g_options._directories = directories::skip;
else
{
output_text_nl(std::cerr, is_a_tty(stderr),
g_options._wa_text.c_str(),
std::format("{}invalid argument '{}' for '--directories'\n"
"Valid arguments are:\n"
" - 'read'\n"
" - 'recurse'\n"
" - 'skip'",
gg_text(),
value));
show_usage();
}
}
},
{
option::type::output,
'r',
"recursive",
nullptr,
"like --directories=recurse",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._directories = directories::recurse;
}
},
{
option::type::output,
'R',
"dereference-recursive",
nullptr,
"likewise, but follow all symlinks",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
g_options._directories = directories::recurse;
g_options._follow_symlinks = true;
}
},
{
option::type::output,
'\0',
"include",
"GLOB",
"search only files that match GLOB (a file pattern)",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
const char* first = value.data();
const char* end = nullptr;
const char* second = first + value.size();
do
{
const auto idx = value.find_first_of(';', first - value.data());
end = idx == std::string_view::npos ?
second :
value.data() + idx;
add_pathname(first, end, g_options._include);
if (end != second)
++end;
first = end;
} while (end != second);
}
},
{
option::type::output,
'\0',
"exclude",
"GLOB",
"skip files that match GLOB",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
const char* first = value.data();
const char* end = nullptr;
const char* second = first + value.size();
do
{
const auto idx = value.find_first_of(';', first - value.data());
end = idx == std::string_view::npos ?
second :
value.data() + idx;
add_pathname(first, end, g_options._exclude);
if (end != second)
++end;
first = end;
} while (end != second);
}
},
{
option::type::output,
'\0',
"exclude-from",
"FILE",
"skip files that match any file pattern from FILE",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
// We know that the string is zero terminated
lexertl::memory_file mf(value.data());
const char* first = mf.data();
if (!first)
throw gg_error(std::format("Unable to open {}", value));
const char* second = first + mf.size();
const char* end = first;
do
{
end = std::find_if(end, second,
[](const char c)
{
return c == '\r' || c == '\n';
});
add_pathname(first, end, g_options._exclude);
end = std::find_if(end, second,
[](const char c)
{
return c != '\r' && c != '\n';
});
first = end;
} while (end != second);
}
},
{
option::type::output,
'\0',
"exclude-dir",
"GLOB",
"skip directories that match GLOB",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
const std::string str(value);
auto pathnames = split(str.c_str(), ';');
for (auto& p : pathnames)
{
namespace fs = std::filesystem;
while (!p.empty() && p.ends_with(fs::path::preferred_separator))
p.remove_suffix(1);
if (p[0] == '!')
{
const std::string pathname(&p[1], std::to_address(p.end()));
// Not using emplace_back() for compatibility with Macintosh
g_options._exclude_dirs._negative.push_back({ wildcardtl::wildcard
{ pathname, is_windows() },
// If pathname does not include a wildcard
// store it as a plain string for error reporting.
pathname.find_first_of("*?[") == std::string::npos ?
pathname :
std::string() });
}
else
{
const std::string pathname(p);
// Not using emplace_back() for compatibility with Macintosh
g_options._exclude_dirs._positive.push_back({ wildcardtl::wildcard
{ pathname, is_windows() },
// If pathname does not include a wildcard
// store it as a plain string for error reporting.
pathname.find_first_of("*?[") == std::string::npos ?
pathname :
std::string() });
}
}
}
},
{
option::type::output,
'L',
"files-without-match",
nullptr,
"print only names of FILEs with no selected lines",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._pathname_only = pathname_only::negated;
}
},
{
option::type::output,
'l',
"files-with-matches",
nullptr,
"print only names of FILEs with selected lines",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._pathname_only = pathname_only::yes;
}
},
{
option::type::output,
'c',
"count",
nullptr,
"print only a count of selected lines per FILE",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._show_count = true;
}
},
{
option::type::output,
'T',
"initial-tab",
nullptr,
"make tabs line up (if needed)",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._initial_tab = true;
}
},
{
option::type::output,
'Z',
"null",
nullptr,
"print 0 byte after FILE name",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._print_null = true;
}
},
{
option::type::context,
'B',
"before-context",
"NUM",
"print NUM lines of leading context",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>&)
{
validate_value(i, argv, longp, value);
g_options._hit_separator = true;
std::from_chars(value.data(), value.data() + value.size(),
g_options._before_context);
}
},
{
option::type::context,
'A',
"after-context",
"NUM",
"print NUM lines of trailing context",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>&)
{
validate_value(i, argv, longp, value);
g_options._hit_separator = true;
std::from_chars(value.data(), value.data() + value.size(),
g_options._after_context);
}
},
{
option::type::context,
'C',
"context",
"NUM",
"print NUM lines of output context",
[](int& i, const bool longp, const char* const argv[],
std::string_view value, std::vector<config>&)
{
validate_value(i, argv, longp, value);
g_options._hit_separator = true;
std::from_chars(value.data(), value.data() + value.size(),
g_options._before_context);
g_options._after_context = g_options._before_context;
}
},
{
option::type::context,
'0',
nullptr,
nullptr,
"same as --context=NUM",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
// Handled in process_short() in args.cpp
}
},
{
option::type::context,
'\0',
"group-separator",
"SEP",
"print SEP on line between matches with context",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
g_options._separator = value;
}
},
{
option::type::context,
'\0',
"no-group-separator",
nullptr,
"do not print separator for matches with context",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._separator.clear();
}
},
{
option::type::context,
'\0',
"color",
"[WHEN],",
nullptr,
colour
},
{
option::type::context,
'\0',
"colour",
"[WHEN]",
"use markers to highlight the matching strings;\n"
"WHEN is 'always', 'never', or 'auto'",
colour
},
{
option::type::gram_grep,
'\0',
"checkout",
"CMD",
"checkout command (include $1 for pathname)",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
// "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"
// checkout $1
// *NOTE* $1 is replaced by the pathname
g_options._checkout = value;
}
},
{
option::type::gram_grep,
'\0',
"config",
"CONFIG_FILE",
"search using config file",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>& configs)
{
const std::string str(value);
auto pathnames = split(str.c_str(), ';');
for (const auto& p : pathnames)
{
auto pn = p.data();
configs.emplace_back(match_type::parser,
std::string(pn, pn + p.size()), g_flags,
g_options._conditions);
}
g_flags = 0;
g_options._conditions.clear();
}
},
{
option::type::gram_grep,
'\0',
"display-whole-match",
nullptr,
"display a multiline match",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._whole_match = true;
}
},
{
option::type::gram_grep,
'\0',
"dump",
nullptr,
"dump DFA regexp",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._dump = dump::text;
}
},
{
option::type::gram_grep,
'\0',
"dump-argv",
nullptr,
"dump command line arguments",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._dump_argv = true;
}
},
{
option::type::gram_grep,
'\0',
"dump-dot",
nullptr,
"dump DFA regexp in DOT format",
[](int&, const bool, const char* const [],
std::string_view, std::vector<config>&)
{
g_options._dump = dump::dot;
}
},
{
option::type::gram_grep,
'\0',
"exec",
"CMD",
"Executes the supplied command",
[](int&, const bool, const char* const [],
std::string_view value, std::vector<config>&)
{
g_options._exec = value;
}
},
{
option::type::gram_grep,
'\0',
"extend-search",
nullptr,
"extend the end of the next match to be the current match",
[](int&, const bool, const char* const [], std::string_view,
std::vector<config>&)
{
// Use the lexertl enum operator
using namespace lexertl;
g_flags |= *config_flags::extend_search;
}
},
{
option::type::gram_grep,
'\0',