You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
deploy: f0e8d44e6e
This commit is contained in:
@@ -645,7 +645,6 @@
|
||||
<a href="#645" id="645">645</a>
|
||||
<a href="#646" id="646">646</a>
|
||||
<a href="#647" id="647">647</a>
|
||||
<a href="#648" id="648">648</a>
|
||||
</pre><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
|
||||
//
|
||||
// (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||
@@ -681,11 +680,10 @@
|
||||
</span><span class="kw">use </span>std::os::unix::fs::FileTypeExt;
|
||||
<span class="attr">#[cfg(unix)]
|
||||
</span><span class="kw">use </span>std::os::unix::net::UnixStream;
|
||||
<span class="kw">use </span>uucore::format_usage;
|
||||
<span class="kw">use </span>uucore::{format_usage, help_section, help_usage};
|
||||
|
||||
<span class="kw">static </span>USAGE: <span class="kw-2">&</span>str = <span class="string">"{} [OPTION]... [FILE]..."</span>;
|
||||
<span class="kw">static </span>ABOUT: <span class="kw-2">&</span>str = <span class="string">"Concatenate FILE(s), or standard input, to standard output
|
||||
With no FILE, or when FILE is -, read standard input."</span>;
|
||||
<span class="kw">const </span>USAGE: <span class="kw-2">&</span>str = <span class="macro">help_usage!</span>(<span class="string">"cat.md"</span>);
|
||||
<span class="kw">const </span>ABOUT: <span class="kw-2">&</span>str = <span class="macro">help_section!</span>(<span class="string">"about"</span>, <span class="string">"cat.md"</span>);
|
||||
|
||||
<span class="attr">#[derive(Error, Debug)]
|
||||
</span><span class="kw">enum </span>CatError {
|
||||
|
||||
@@ -240,21 +240,12 @@
|
||||
<span class="kw">pub const </span>TOTAL: <span class="kw-2">&</span>str = <span class="string">"total"</span>;
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>mkdelim(col: usize, opts: <span class="kw-2">&</span>ArgMatches) -> String {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>s = String::new();
|
||||
<span class="kw">let </span>delim = <span class="kw">match </span>opts.get_one::<String>(options::DELIMITER).unwrap().as_str() {
|
||||
<span class="string">"" </span>=> <span class="string">"\0"</span>,
|
||||
delim => delim,
|
||||
};
|
||||
|
||||
<span class="kw">if </span>col > <span class="number">1 </span>&& !opts.get_flag(options::COLUMN_1) {
|
||||
s.push_str(delim.as_ref());
|
||||
}
|
||||
<span class="kw">if </span>col > <span class="number">2 </span>&& !opts.get_flag(options::COLUMN_2) {
|
||||
s.push_str(delim.as_ref());
|
||||
}
|
||||
|
||||
s
|
||||
<span class="kw">fn </span>column_width(col: <span class="kw-2">&</span>str, opts: <span class="kw-2">&</span>ArgMatches) -> usize {
|
||||
<span class="kw">if </span>opts.get_flag(col) {
|
||||
<span class="number">0
|
||||
</span>} <span class="kw">else </span>{
|
||||
<span class="number">1
|
||||
</span>}
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>ensure_nl(line: <span class="kw-2">&mut </span>String) {
|
||||
@@ -278,7 +269,16 @@
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>comm(a: <span class="kw-2">&mut </span>LineReader, b: <span class="kw-2">&mut </span>LineReader, opts: <span class="kw-2">&</span>ArgMatches) {
|
||||
<span class="kw">let </span>delim: Vec<String> = (<span class="number">0</span>..<span class="number">4</span>).map(|col| mkdelim(col, opts)).collect();
|
||||
<span class="kw">let </span>delim = <span class="kw">match </span>opts.get_one::<String>(options::DELIMITER).unwrap().as_str() {
|
||||
<span class="string">"" </span>=> <span class="string">"\0"</span>,
|
||||
delim => delim,
|
||||
};
|
||||
|
||||
<span class="kw">let </span>width_col_1 = column_width(options::COLUMN_1, opts);
|
||||
<span class="kw">let </span>width_col_2 = column_width(options::COLUMN_2, opts);
|
||||
|
||||
<span class="kw">let </span>delim_col_2 = delim.repeat(width_col_1);
|
||||
<span class="kw">let </span>delim_col_3 = delim.repeat(width_col_1 + width_col_2);
|
||||
|
||||
<span class="kw">let </span>ra = <span class="kw-2">&mut </span>String::new();
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>na = a.read_line(ra);
|
||||
@@ -306,7 +306,7 @@
|
||||
Ordering::Less => {
|
||||
<span class="kw">if </span>!opts.get_flag(options::COLUMN_1) {
|
||||
ensure_nl(ra);
|
||||
<span class="macro">print!</span>(<span class="string">"{}{}"</span>, delim[<span class="number">1</span>], ra);
|
||||
<span class="macro">print!</span>(<span class="string">"{ra}"</span>);
|
||||
}
|
||||
ra.clear();
|
||||
na = a.read_line(ra);
|
||||
@@ -315,7 +315,7 @@
|
||||
Ordering::Greater => {
|
||||
<span class="kw">if </span>!opts.get_flag(options::COLUMN_2) {
|
||||
ensure_nl(rb);
|
||||
<span class="macro">print!</span>(<span class="string">"{}{}"</span>, delim[<span class="number">2</span>], rb);
|
||||
<span class="macro">print!</span>(<span class="string">"{delim_col_2}{rb}"</span>);
|
||||
}
|
||||
rb.clear();
|
||||
nb = b.read_line(rb);
|
||||
@@ -324,7 +324,7 @@
|
||||
Ordering::Equal => {
|
||||
<span class="kw">if </span>!opts.get_flag(options::COLUMN_3) {
|
||||
ensure_nl(ra);
|
||||
<span class="macro">print!</span>(<span class="string">"{}{}"</span>, delim[<span class="number">3</span>], ra);
|
||||
<span class="macro">print!</span>(<span class="string">"{delim_col_3}{ra}"</span>);
|
||||
}
|
||||
ra.clear();
|
||||
rb.clear();
|
||||
@@ -336,7 +336,7 @@
|
||||
}
|
||||
|
||||
<span class="kw">if </span>opts.get_flag(options::TOTAL) {
|
||||
<span class="macro">println!</span>(<span class="string">"{total_col_1}\t{total_col_2}\t{total_col_3}\ttotal"</span>);
|
||||
<span class="macro">println!</span>(<span class="string">"{total_col_1}{delim}{total_col_2}{delim}{total_col_3}{delim}total"</span>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1861,9 +1861,6 @@
|
||||
<a href="#1861" id="1861">1861</a>
|
||||
<a href="#1862" id="1862">1862</a>
|
||||
<a href="#1863" id="1863">1863</a>
|
||||
<a href="#1864" id="1864">1864</a>
|
||||
<a href="#1865" id="1865">1865</a>
|
||||
<a href="#1866" id="1866">1866</a>
|
||||
</pre><pre class="rust"><code><span class="attr">#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(clippy::extra_unused_lifetimes)]
|
||||
|
||||
@@ -1906,7 +1903,7 @@
|
||||
<span class="kw">use </span>uucore::fs::{
|
||||
canonicalize, paths_refer_to_same_file, FileInformation, MissingHandling, ResolveMode,
|
||||
};
|
||||
<span class="kw">use </span>uucore::{crash, format_usage, prompt_yes, show_error, show_warning};
|
||||
<span class="kw">use </span>uucore::{crash, format_usage, help_section, help_usage, prompt_yes, show_error, show_warning};
|
||||
|
||||
<span class="kw">use </span><span class="kw">crate</span>::copydir::copy_directory;
|
||||
|
||||
@@ -2094,13 +2091,10 @@
|
||||
progress_bar: bool,
|
||||
}
|
||||
|
||||
<span class="kw">static </span>ABOUT: <span class="kw-2">&</span>str = <span class="string">"Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY."</span>;
|
||||
<span class="kw">const </span>ABOUT: <span class="kw-2">&</span>str = <span class="macro">help_section!</span>(<span class="string">"about"</span>, <span class="string">"cp.md"</span>);
|
||||
<span class="kw">static </span>EXIT_ERR: i32 = <span class="number">1</span>;
|
||||
|
||||
<span class="kw">const </span>USAGE: <span class="kw-2">&</span>str = <span class="string">"\
|
||||
{} [OPTION]... [-T] SOURCE DEST
|
||||
{} [OPTION]... SOURCE... DIRECTORY
|
||||
{} [OPTION]... -t DIRECTORY SOURCE..."</span>;
|
||||
<span class="kw">const </span>USAGE: <span class="kw-2">&</span>str = <span class="macro">help_usage!</span>(<span class="string">"cp.md"</span>);
|
||||
|
||||
<span class="comment">// Argument constants
|
||||
</span><span class="kw">mod </span>options {
|
||||
|
||||
@@ -515,18 +515,24 @@
|
||||
<a href="#515" id="515">515</a>
|
||||
<a href="#516" id="516">516</a>
|
||||
<a href="#517" id="517">517</a>
|
||||
<a href="#518" id="518">518</a>
|
||||
<a href="#519" id="519">519</a>
|
||||
<a href="#520" id="520">520</a>
|
||||
<a href="#521" id="521">521</a>
|
||||
<a href="#522" id="522">522</a>
|
||||
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) kqueue Signum
|
||||
// spell-checker:ignore (ToDO) kqueue Signum fundu
|
||||
|
||||
</span><span class="kw">use </span><span class="kw">crate</span>::paths::Input;
|
||||
<span class="kw">use crate</span>::{parse, platform, Quotable};
|
||||
<span class="kw">use </span>atty::Stream;
|
||||
<span class="kw">use </span>clap::crate_version;
|
||||
<span class="kw">use </span>clap::{parser::ValueSource, Arg, ArgAction, ArgMatches, Command};
|
||||
<span class="kw">use </span>fundu::DurationParser;
|
||||
<span class="kw">use </span>same_file::Handle;
|
||||
<span class="kw">use </span>std::collections::VecDeque;
|
||||
<span class="kw">use </span>std::ffi::OsString;
|
||||
@@ -665,16 +671,20 @@
|
||||
settings.retry =
|
||||
matches.get_flag(options::RETRY) || matches.get_flag(options::FOLLOW_RETRY);
|
||||
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(s) = matches.get_one::<String>(options::SLEEP_INT) {
|
||||
settings.sleep_sec = <span class="kw">match </span>s.parse::<f32>() {
|
||||
<span class="prelude-val">Ok</span>(s) => Duration::from_secs_f32(s),
|
||||
<span class="prelude-val">Err</span>(<span class="kw">_</span>) => {
|
||||
<span class="kw">return </span><span class="prelude-val">Err</span>(UUsageError::new(
|
||||
<span class="number">1</span>,
|
||||
<span class="macro">format!</span>(<span class="string">"invalid number of seconds: {}"</span>, s.quote()),
|
||||
))
|
||||
}
|
||||
}
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(source) = matches.get_one::<String>(options::SLEEP_INT) {
|
||||
<span class="comment">// Advantage of `fundu` over `Duration::(try_)from_secs_f64(source.parse().unwrap())`:
|
||||
// * doesn't panic on errors like `Duration::from_secs_f64` would.
|
||||
// * no precision loss, rounding errors or other floating point problems.
|
||||
// * evaluates to `Duration::MAX` if the parsed number would have exceeded
|
||||
// `DURATION::MAX` or `infinity` was given
|
||||
// * not applied here but it supports customizable time units and provides better error
|
||||
// messages
|
||||
</span>settings.sleep_sec =
|
||||
DurationParser::without_time_units()
|
||||
.parse(source)
|
||||
.map_err(|<span class="kw">_</span>| {
|
||||
UUsageError::new(<span class="number">1</span>, <span class="macro">format!</span>(<span class="string">"invalid number of seconds: '{source}'"</span>))
|
||||
})<span class="question-mark">?</span>;
|
||||
}
|
||||
|
||||
settings.use_polling = matches.get_flag(options::USE_POLLING);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user