|
582 | 582 | <a href="#582" id="582">582</a>
|
583 | 583 | <a href="#583" id="583">583</a>
|
584 | 584 | <a href="#584" id="584">584</a>
|
585 |
| -<a href="#585" id="585">585</a> |
586 |
| -<a href="#586" id="586">586</a> |
587 |
| -<a href="#587" id="587">587</a> |
588 |
| -<a href="#588" id="588">588</a> |
589 |
| -<a href="#589" id="589">589</a> |
590 |
| -<a href="#590" id="590">590</a> |
591 |
| -<a href="#591" id="591">591</a> |
592 |
| -<a href="#592" id="592">592</a> |
593 |
| -<a href="#593" id="593">593</a> |
594 |
| -<a href="#594" id="594">594</a> |
595 |
| -<a href="#595" id="595">595</a> |
596 |
| -<a href="#596" id="596">596</a> |
597 |
| -<a href="#597" id="597">597</a> |
598 |
| -<a href="#598" id="598">598</a> |
599 |
| -<a href="#599" id="599">599</a> |
600 |
| -<a href="#600" id="600">600</a> |
601 |
| -<a href="#601" id="601">601</a> |
602 |
| -<a href="#602" id="602">602</a> |
603 |
| -<a href="#603" id="603">603</a> |
604 |
| -<a href="#604" id="604">604</a> |
605 |
| -<a href="#605" id="605">605</a> |
606 |
| -<a href="#606" id="606">606</a> |
607 |
| -<a href="#607" id="607">607</a> |
608 |
| -<a href="#608" id="608">608</a> |
609 |
| -<a href="#609" id="609">609</a> |
610 |
| -<a href="#610" id="610">610</a> |
611 |
| -<a href="#611" id="611">611</a> |
612 |
| -<a href="#612" id="612">612</a> |
613 |
| -<a href="#613" id="613">613</a> |
614 |
| -<a href="#614" id="614">614</a> |
615 |
| -<a href="#615" id="615">615</a> |
616 |
| -<a href="#616" id="616">616</a> |
617 |
| -<a href="#617" id="617">617</a> |
618 |
| -<a href="#618" id="618">618</a> |
619 |
| -<a href="#619" id="619">619</a> |
620 |
| -<a href="#620" id="620">620</a> |
621 |
| -<a href="#621" id="621">621</a> |
622 |
| -<a href="#622" id="622">622</a> |
623 |
| -<a href="#623" id="623">623</a> |
624 |
| -<a href="#624" id="624">624</a> |
625 |
| -<a href="#625" id="625">625</a> |
626 |
| -<a href="#626" id="626">626</a> |
627 |
| -<a href="#627" id="627">627</a> |
628 |
| -<a href="#628" id="628">628</a> |
629 |
| -<a href="#629" id="629">629</a> |
630 |
| -<a href="#630" id="630">630</a> |
631 |
| -<a href="#631" id="631">631</a> |
632 |
| -<a href="#632" id="632">632</a> |
633 |
| -<a href="#633" id="633">633</a> |
634 |
| -<a href="#634" id="634">634</a> |
635 |
| -<a href="#635" id="635">635</a> |
636 |
| -<a href="#636" id="636">636</a> |
637 |
| -<a href="#637" id="637">637</a> |
638 |
| -<a href="#638" id="638">638</a> |
639 |
| -<a href="#639" id="639">639</a> |
640 |
| -<a href="#640" id="640">640</a> |
641 |
| -<a href="#641" id="641">641</a> |
642 |
| -<a href="#642" id="642">642</a> |
643 |
| -<a href="#643" id="643">643</a> |
644 |
| -<a href="#644" id="644">644</a> |
645 |
| -<a href="#645" id="645">645</a> |
646 |
| -<a href="#646" id="646">646</a> |
647 |
| -<a href="#647" id="647">647</a> |
648 |
| -<a href="#648" id="648">648</a> |
649 |
| -<a href="#649" id="649">649</a> |
650 |
| -<a href="#650" id="650">650</a> |
651 |
| -<a href="#651" id="651">651</a> |
652 |
| -<a href="#652" id="652">652</a> |
653 |
| -<a href="#653" id="653">653</a> |
654 |
| -<a href="#654" id="654">654</a> |
655 |
| -<a href="#655" id="655">655</a> |
656 |
| -<a href="#656" id="656">656</a> |
657 |
| -<a href="#657" id="657">657</a> |
658 |
| -<a href="#658" id="658">658</a> |
659 |
| -<a href="#659" id="659">659</a> |
660 |
| -<a href="#660" id="660">660</a> |
661 |
| -<a href="#661" id="661">661</a> |
662 |
| -<a href="#662" id="662">662</a> |
663 |
| -<a href="#663" id="663">663</a> |
664 |
| -<a href="#664" id="664">664</a> |
665 |
| -<a href="#665" id="665">665</a> |
666 |
| -<a href="#666" id="666">666</a> |
667 |
| -<a href="#667" id="667">667</a> |
668 |
| -<a href="#668" id="668">668</a> |
669 |
| -<a href="#669" id="669">669</a> |
670 | 585 | </pre><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
|
671 | 586 | //
|
672 | 587 | // (c) Rolf Morel <rolfmorel@gmail.com>
|
|
688 | 603 | <span class="kw">use </span><span class="self">self</span>::searcher::Searcher;
|
689 | 604 | <span class="kw">use </span>matcher::{ExactMatcher, Matcher, WhitespaceMatcher};
|
690 | 605 | <span class="kw">use </span>uucore::ranges::Range;
|
691 |
| -<span class="kw">use </span>uucore::{format_usage, show, show_error, show_if_err}; |
| 606 | +<span class="kw">use </span>uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_if_err}; |
692 | 607 |
|
693 | 608 | <span class="kw">mod </span>matcher;
|
694 | 609 | <span class="kw">mod </span>searcher;
|
695 | 610 |
|
696 |
| -<span class="kw">static </span>USAGE: <span class="kw-2">&</span>str = |
697 |
| - <span class="string">"{} [-d|-w] [-s] [-z] [--output-delimiter] ((-f|-b|-c) {{sequence}}) {{sourcefile}}+"</span>; |
698 |
| -<span class="kw">static </span>ABOUT: <span class="kw-2">&</span>str = |
699 |
| - <span class="string">"Prints specified byte or field columns from each line of stdin or the input files"</span>; |
700 |
| -<span class="kw">static </span>LONG_HELP: <span class="kw-2">&</span>str = <span class="string">" |
701 |
| - Each call must specify a mode (what to use for columns), |
702 |
| - a sequence (which columns to print), and provide a data source |
703 |
| - |
704 |
| - Specifying a mode |
705 |
| - |
706 |
| - Use --bytes (-b) or --characters (-c) to specify byte mode |
707 |
| - |
708 |
| - Use --fields (-f) to specify field mode, where each line is broken into |
709 |
| - fields identified by a delimiter character. For example for a typical CSV |
710 |
| - you could use this in combination with setting comma as the delimiter |
711 |
| - |
712 |
| - Specifying a sequence |
713 |
| - |
714 |
| - A sequence is a group of 1 or more numbers or inclusive ranges separated |
715 |
| - by a commas. |
716 |
| - |
717 |
| - cut -f 2,5-7 some_file.txt |
718 |
| - will display the 2nd, 5th, 6th, and 7th field for each source line |
719 |
| - |
720 |
| - Ranges can extend to the end of the row by excluding the the second number |
721 |
| - |
722 |
| - cut -f 3- some_file.txt |
723 |
| - will display the 3rd field and all fields after for each source line |
724 |
| - |
725 |
| - The first number of a range can be excluded, and this is effectively the |
726 |
| - same as using 1 as the first number: it causes the range to begin at the |
727 |
| - first column. Ranges can also display a single column |
728 |
| - |
729 |
| - cut -f 1,3-5 some_file.txt |
730 |
| - will display the 1st, 3rd, 4th, and 5th field for each source line |
731 |
| - |
732 |
| - The --complement option, when used, inverts the effect of the sequence |
733 |
| - |
734 |
| - cut --complement -f 4-6 some_file.txt |
735 |
| - will display the every field but the 4th, 5th, and 6th |
736 |
| - |
737 |
| - Specifying a data source |
738 |
| - |
739 |
| - If no sourcefile arguments are specified, stdin is used as the source of |
740 |
| - lines to print |
741 |
| - |
742 |
| - If sourcefile arguments are specified, stdin is ignored and all files are |
743 |
| - read in consecutively if a sourcefile is not successfully read, a warning |
744 |
| - will print to stderr, and the eventual status code will be 1, but cut |
745 |
| - will continue to read through proceeding sourcefiles |
746 |
| - |
747 |
| - To print columns from both STDIN and a file argument, use - (dash) as a |
748 |
| - sourcefile argument to represent stdin. |
749 |
| - |
750 |
| - Field Mode options |
751 |
| - |
752 |
| - The fields in each line are identified by a delimiter (separator) |
753 |
| - |
754 |
| - Set the delimiter |
755 |
| - Set the delimiter which separates fields in the file using the |
756 |
| - --delimiter (-d) option. Setting the delimiter is optional. |
757 |
| - If not set, a default delimiter of Tab will be used. |
758 |
| - |
759 |
| - If the -w option is provided, fields will be separated by any number |
760 |
| - of whitespace characters (Space and Tab). The output delimiter will |
761 |
| - be a Tab unless explicitly specified. Only one of -d or -w option can be specified. |
762 |
| - This is an extension adopted from FreeBSD. |
763 |
| - |
764 |
| - Optionally Filter based on delimiter |
765 |
| - If the --only-delimited (-s) flag is provided, only lines which |
766 |
| - contain the delimiter will be printed |
767 |
| - |
768 |
| - Replace the delimiter |
769 |
| - If the --output-delimiter option is provided, the argument used for |
770 |
| - it will replace the delimiter character in each line printed. This is |
771 |
| - useful for transforming tabular data - e.g. to convert a CSV to a |
772 |
| - TSV (tab-separated file) |
773 |
| - |
774 |
| - Line endings |
775 |
| - |
776 |
| - When the --zero-terminated (-z) option is used, cut sees \\0 (null) as the |
777 |
| - 'line ending' character (both for the purposes of reading lines and |
778 |
| - separating printed lines) instead of \\n (newline). This is useful for |
779 |
| - tabular data where some of the cells may contain newlines |
780 |
| - |
781 |
| - echo 'ab\\0cd' | cut -z -c 1 |
782 |
| - will result in 'a\\0c\\0' |
783 |
| -"</span>; |
| 611 | +<span class="kw">const </span>USAGE: <span class="kw-2">&</span>str = <span class="macro">help_usage!</span>(<span class="string">"cut.md"</span>); |
| 612 | +<span class="kw">const </span>ABOUT: <span class="kw-2">&</span>str = <span class="macro">help_about!</span>(<span class="string">"cut.md"</span>); |
| 613 | +<span class="kw">const </span>AFTER_HELP: <span class="kw-2">&</span>str = <span class="macro">help_section!</span>(<span class="string">"after help"</span>, <span class="string">"cut.md"</span>); |
784 | 614 |
|
785 | 615 | <span class="kw">struct </span>Options {
|
786 | 616 | out_delim: <span class="prelude-ty">Option</span><String>,
|
|
1263 | 1093 | .version(<span class="macro">crate_version!</span>())
|
1264 | 1094 | .override_usage(format_usage(USAGE))
|
1265 | 1095 | .about(ABOUT)
|
1266 |
| - .after_help(LONG_HELP) |
| 1096 | + .after_help(AFTER_HELP) |
1267 | 1097 | .infer_long_args(<span class="bool-val">true</span>)
|
1268 | 1098 | .arg(
|
1269 | 1099 | Arg::new(options::BYTES)
|
|
0 commit comments