Skip to content

Commit 7841d33

Browse files
committed
deploy: f0e8d44
1 parent 7b47e60 commit 7841d33

17 files changed

+119
-39
lines changed

dev/src/uu_more/more.rs.html

+103-23
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,46 @@
523523
<a href="#523" id="523">523</a>
524524
<a href="#524" id="524">524</a>
525525
<a href="#525" id="525">525</a>
526+
<a href="#526" id="526">526</a>
527+
<a href="#527" id="527">527</a>
528+
<a href="#528" id="528">528</a>
529+
<a href="#529" id="529">529</a>
530+
<a href="#530" id="530">530</a>
531+
<a href="#531" id="531">531</a>
532+
<a href="#532" id="532">532</a>
533+
<a href="#533" id="533">533</a>
534+
<a href="#534" id="534">534</a>
535+
<a href="#535" id="535">535</a>
536+
<a href="#536" id="536">536</a>
537+
<a href="#537" id="537">537</a>
538+
<a href="#538" id="538">538</a>
539+
<a href="#539" id="539">539</a>
540+
<a href="#540" id="540">540</a>
541+
<a href="#541" id="541">541</a>
542+
<a href="#542" id="542">542</a>
543+
<a href="#543" id="543">543</a>
544+
<a href="#544" id="544">544</a>
545+
<a href="#545" id="545">545</a>
546+
<a href="#546" id="546">546</a>
547+
<a href="#547" id="547">547</a>
548+
<a href="#548" id="548">548</a>
549+
<a href="#549" id="549">549</a>
550+
<a href="#550" id="550">550</a>
551+
<a href="#551" id="551">551</a>
552+
<a href="#552" id="552">552</a>
553+
<a href="#553" id="553">553</a>
554+
<a href="#554" id="554">554</a>
555+
<a href="#555" id="555">555</a>
556+
<a href="#556" id="556">556</a>
557+
<a href="#557" id="557">557</a>
558+
<a href="#558" id="558">558</a>
559+
<a href="#559" id="559">559</a>
560+
<a href="#560" id="560">560</a>
561+
<a href="#561" id="561">561</a>
562+
<a href="#562" id="562">562</a>
563+
<a href="#563" id="563">563</a>
564+
<a href="#564" id="564">564</a>
565+
<a href="#565" id="565">565</a>
526566
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
527567
// *
528568
// * (c) Martin Kysel &lt;code@martinkysel.com&gt;
@@ -539,13 +579,14 @@
539579
time::Duration,
540580
};
541581

542-
<span class="kw">use </span>clap::{crate_version, Arg, ArgAction, Command};
582+
<span class="kw">use </span>clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
543583
<span class="kw">use </span>crossterm::event::KeyEventKind;
544584
<span class="kw">use </span>crossterm::{
585+
cursor::MoveTo,
545586
event::{<span class="self">self</span>, Event, KeyCode, KeyEvent, KeyModifiers},
546587
execute, queue,
547588
style::Attribute,
548-
terminal,
589+
terminal::{<span class="self">self</span>, Clear, ClearType},
549590
};
550591

551592
<span class="kw">use </span>is_terminal::IsTerminal;
@@ -576,12 +617,34 @@
576617

577618
<span class="kw">const </span>MULTI_FILE_TOP_PROMPT: <span class="kw-2">&amp;</span>str = <span class="string">&quot;::::::::::::::\n{}\n::::::::::::::\n&quot;</span>;
578619

620+
<span class="kw">struct </span>Options {
621+
silent: bool,
622+
clean_print: bool,
623+
print_over: bool,
624+
}
625+
626+
<span class="kw">impl </span>Options {
627+
<span class="kw">fn </span>from(matches: <span class="kw-2">&amp;</span>ArgMatches) -&gt; <span class="self">Self </span>{
628+
<span class="self">Self </span>{
629+
silent: matches.get_flag(options::SILENT),
630+
clean_print: matches.get_flag(options::CLEAN_PRINT),
631+
print_over: matches.get_flag(options::PRINT_OVER),
632+
}
633+
}
634+
}
635+
579636
<span class="attr">#[uucore::main]
580637
</span><span class="kw">pub fn </span>uumain(args: <span class="kw">impl </span>uucore::Args) -&gt; UResult&lt;()&gt; {
581-
<span class="kw">let </span>matches = uu_app().get_matches_from(args);
638+
<span class="kw">let </span>args = args.collect_lossy();
639+
<span class="kw">let </span>matches = <span class="kw">match </span>uu_app().try_get_matches_from(<span class="kw-2">&amp;</span>args) {
640+
<span class="prelude-val">Ok</span>(m) =&gt; m,
641+
<span class="prelude-val">Err</span>(e) =&gt; <span class="kw">return </span><span class="prelude-val">Err</span>(e.into()),
642+
};
643+
644+
<span class="kw">let </span>options = Options::from(<span class="kw-2">&amp;</span>matches);
582645

583646
<span class="kw">let </span><span class="kw-2">mut </span>buff = String::new();
584-
<span class="kw">let </span>silent = matches.get_flag(options::SILENT);
647+
585648
<span class="kw">if let </span><span class="prelude-val">Some</span>(files) = matches.get_many::&lt;String&gt;(options::FILES) {
586649
<span class="kw">let </span><span class="kw-2">mut </span>stdout = setup_term();
587650
<span class="kw">let </span>length = files.len();
@@ -608,14 +671,14 @@
608671
}
609672
<span class="kw">let </span><span class="kw-2">mut </span>reader = BufReader::new(File::open(file).unwrap());
610673
reader.read_to_string(<span class="kw-2">&amp;mut </span>buff).unwrap();
611-
more(<span class="kw-2">&amp;</span>buff, <span class="kw-2">&amp;mut </span>stdout, next_file.copied(), silent)<span class="question-mark">?</span>;
674+
more(<span class="kw-2">&amp;</span>buff, <span class="kw-2">&amp;mut </span>stdout, next_file.copied(), <span class="kw-2">&amp;</span>options)<span class="question-mark">?</span>;
612675
buff.clear();
613676
}
614677
reset_term(<span class="kw-2">&amp;mut </span>stdout);
615678
} <span class="kw">else if </span>!std::io::stdin().is_terminal() {
616679
stdin().read_to_string(<span class="kw-2">&amp;mut </span>buff).unwrap();
617680
<span class="kw">let </span><span class="kw-2">mut </span>stdout = setup_term();
618-
more(<span class="kw-2">&amp;</span>buff, <span class="kw-2">&amp;mut </span>stdout, <span class="prelude-val">None</span>, silent)<span class="question-mark">?</span>;
681+
more(<span class="kw-2">&amp;</span>buff, <span class="kw-2">&amp;mut </span>stdout, <span class="prelude-val">None</span>, <span class="kw-2">&amp;</span>options)<span class="question-mark">?</span>;
619682
reset_term(<span class="kw-2">&amp;mut </span>stdout);
620683
} <span class="kw">else </span>{
621684
<span class="kw">return </span><span class="prelude-val">Err</span>(UUsageError::new(<span class="number">1</span>, <span class="string">&quot;bad usage&quot;</span>));
@@ -629,13 +692,27 @@
629692
.override_usage(format_usage(USAGE))
630693
.version(<span class="macro">crate_version!</span>())
631694
.infer_long_args(<span class="bool-val">true</span>)
695+
.arg(
696+
Arg::new(options::PRINT_OVER)
697+
.short(<span class="string">&#39;c&#39;</span>)
698+
.long(options::PRINT_OVER)
699+
.help(<span class="string">&quot;Do not scroll, display text and clean line ends&quot;</span>)
700+
.action(ArgAction::SetTrue),
701+
)
632702
.arg(
633703
Arg::new(options::SILENT)
634704
.short(<span class="string">&#39;d&#39;</span>)
635705
.long(options::SILENT)
636706
.help(<span class="string">&quot;Display help instead of ringing bell&quot;</span>)
637707
.action(ArgAction::SetTrue),
638708
)
709+
.arg(
710+
Arg::new(options::CLEAN_PRINT)
711+
.short(<span class="string">&#39;p&#39;</span>)
712+
.long(options::CLEAN_PRINT)
713+
.help(<span class="string">&quot;Do not scroll, clean screen and display text&quot;</span>)
714+
.action(ArgAction::SetTrue),
715+
)
639716
<span class="comment">// The commented arguments below are unimplemented:
640717
/*
641718
.arg(
@@ -650,18 +727,6 @@
650727
.long(options::NO_PAUSE)
651728
.help(&quot;Suppress pause after form feed&quot;),
652729
)
653-
.arg(
654-
Arg::new(options::PRINT_OVER)
655-
.short(&#39;c&#39;)
656-
.long(options::PRINT_OVER)
657-
.help(&quot;Do not scroll, display text and clean line ends&quot;),
658-
)
659-
.arg(
660-
Arg::new(options::CLEAN_PRINT)
661-
.short(&#39;p&#39;)
662-
.long(options::CLEAN_PRINT)
663-
.help(&quot;Do not scroll, clean screen and display text&quot;),
664-
)
665730
.arg(
666731
Arg::new(options::SQUEEZE)
667732
.short(&#39;s&#39;)
@@ -734,7 +799,7 @@
734799
</span><span class="kw">fn </span>reset_term(stdout: <span class="kw-2">&amp;mut </span>std::io::Stdout) {
735800
terminal::disable_raw_mode().unwrap();
736801
<span class="comment">// Clear the prompt
737-
</span><span class="macro">queue!</span>(stdout, terminal::Clear(terminal::ClearType::CurrentLine)).unwrap();
802+
</span><span class="macro">queue!</span>(stdout, terminal::Clear(ClearType::CurrentLine)).unwrap();
738803
<span class="comment">// Move cursor to the beginning without printing new line
739804
</span><span class="macro">print!</span>(<span class="string">&quot;\r&quot;</span>);
740805
stdout.flush().unwrap();
@@ -744,11 +809,16 @@
744809
#[inline(always)]
745810
</span><span class="kw">fn </span>reset_term(<span class="kw">_</span>: <span class="kw-2">&amp;mut </span>usize) {}
746811

747-
<span class="kw">fn </span>more(buff: <span class="kw-2">&amp;</span>str, stdout: <span class="kw-2">&amp;mut </span>Stdout, next_file: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>str&gt;, silent: bool) -&gt; UResult&lt;()&gt; {
812+
<span class="kw">fn </span>more(
813+
buff: <span class="kw-2">&amp;</span>str,
814+
stdout: <span class="kw-2">&amp;mut </span>Stdout,
815+
next_file: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>str&gt;,
816+
options: <span class="kw-2">&amp;</span>Options,
817+
) -&gt; UResult&lt;()&gt; {
748818
<span class="kw">let </span>(cols, rows) = terminal::size().unwrap();
749819
<span class="kw">let </span>lines = break_buff(buff, usize::from(cols));
750820

751-
<span class="kw">let </span><span class="kw-2">mut </span>pager = Pager::new(rows, lines, next_file, silent);
821+
<span class="kw">let </span><span class="kw-2">mut </span>pager = Pager::new(rows, lines, next_file, options);
752822
pager.draw(stdout, <span class="prelude-val">None</span>);
753823
<span class="kw">if </span>pager.should_close() {
754824
<span class="kw">return </span><span class="prelude-val">Ok</span>(());
@@ -838,6 +908,16 @@
838908
<span class="kw">_ </span>=&gt; <span class="kw">continue</span>,
839909
}
840910

911+
<span class="kw">if </span>options.print_over {
912+
<span class="macro">execute!</span>(
913+
std::io::stdout(),
914+
MoveTo(<span class="number">0</span>, <span class="number">0</span>),
915+
Clear(ClearType::FromCursorDown)
916+
)
917+
.unwrap();
918+
} <span class="kw">else if </span>options.clean_print {
919+
<span class="macro">execute!</span>(std::io::stdout(), Clear(ClearType::All), MoveTo(<span class="number">0</span>, <span class="number">0</span>)).unwrap();
920+
}
841921
pager.draw(stdout, wrong_key);
842922
}
843923
}
@@ -855,15 +935,15 @@
855935
}
856936

857937
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;a</span>&gt; Pager&lt;<span class="lifetime">&#39;a</span>&gt; {
858-
<span class="kw">fn </span>new(rows: u16, lines: Vec&lt;String&gt;, next_file: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span>str&gt;, silent: bool) -&gt; <span class="self">Self </span>{
938+
<span class="kw">fn </span>new(rows: u16, lines: Vec&lt;String&gt;, next_file: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span>str&gt;, options: <span class="kw-2">&amp;</span>Options) -&gt; <span class="self">Self </span>{
859939
<span class="kw">let </span>line_count = lines.len();
860940
<span class="self">Self </span>{
861941
upper_mark: <span class="number">0</span>,
862942
content_rows: rows.saturating_sub(<span class="number">1</span>),
863943
lines,
864944
next_file,
865945
line_count,
866-
silent,
946+
silent: options.silent,
867947
}
868948
}
869949

dev/uu_more/fn.uu_app.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `uu_app` fn in crate `uu_more`."><title>uu_app in uu_more - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-c4dbdcde0fbd8430.css" id="mainThemeStyle"><link rel="stylesheet" id="themeStyle" href="../static.files/light-db279b6232be9c13.css"><link rel="stylesheet" disabled href="../static.files/dark-cf923f49f397b216.css"><link rel="stylesheet" disabled href="../static.files/ayu-be46fdc453a55015.css"><script src="../static.files/storage-3891ce972e3a2bf8.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-98a684e84ae5b08b.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-13285aec31fa243e.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="logo-container" href="../uu_more/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2></h2></nav><nav class="sidebar"><a class="logo-container" href="../uu_more/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><div class="sidebar-elems"><h2><a href="index.html">In uu_more</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Function <a href="index.html">uu_more</a>::<wbr><a class="fn" href="#">uu_app</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/uu_more/more.rs.html#101-193">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn uu_app() -&gt; Command</code></pre></section></div></main><div id="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="uu_more" data-themes="" data-resource-suffix="" data-rustdoc-version="1.69.0 (84c898d65 2023-04-16)" data-search-js="search-8a59a8356673ec1f.js" data-settings-js="settings-f0c5c39777a9a2f6.js" data-settings-css="settings-0bcba95ff279c1db.css" ></div></body></html>
1+
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `uu_app` fn in crate `uu_more`."><title>uu_app in uu_more - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-c4dbdcde0fbd8430.css" id="mainThemeStyle"><link rel="stylesheet" id="themeStyle" href="../static.files/light-db279b6232be9c13.css"><link rel="stylesheet" disabled href="../static.files/dark-cf923f49f397b216.css"><link rel="stylesheet" disabled href="../static.files/ayu-be46fdc453a55015.css"><script src="../static.files/storage-3891ce972e3a2bf8.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-98a684e84ae5b08b.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-13285aec31fa243e.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="logo-container" href="../uu_more/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2></h2></nav><nav class="sidebar"><a class="logo-container" href="../uu_more/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><div class="sidebar-elems"><h2><a href="index.html">In uu_more</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Function <a href="index.html">uu_more</a>::<wbr><a class="fn" href="#">uu_app</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/uu_more/more.rs.html#124-218">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn uu_app() -&gt; Command</code></pre></section></div></main><div id="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="uu_more" data-themes="" data-resource-suffix="" data-rustdoc-version="1.69.0 (84c898d65 2023-04-16)" data-search-js="search-8a59a8356673ec1f.js" data-settings-js="settings-f0c5c39777a9a2f6.js" data-settings-css="settings-0bcba95ff279c1db.css" ></div></body></html>

0 commit comments

Comments
 (0)