mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2026-01-16 10:11:01 +00:00
mv: resolve merge conflict
This commit is contained in:
commit
85ded232bc
35 changed files with 550 additions and 209 deletions
|
|
@ -43,8 +43,8 @@ fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
|
|||
}
|
||||
}
|
||||
|
||||
fn name(binary_path: &Path) -> &str {
|
||||
binary_path.file_stem().unwrap().to_str().unwrap()
|
||||
fn name(binary_path: &Path) -> Option<&str> {
|
||||
binary_path.file_stem()?.to_str()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -54,7 +54,10 @@ fn main() {
|
|||
let mut args = uucore::args_os();
|
||||
|
||||
let binary = binary_path(&mut args);
|
||||
let binary_as_util = name(&binary);
|
||||
let binary_as_util = name(&binary).unwrap_or_else(|| {
|
||||
usage(&utils, "<unknown binary name>");
|
||||
process::exit(0);
|
||||
});
|
||||
|
||||
// binary name equals util name?
|
||||
if let Some(&(uumain, _)) = utils.get(binary_as_util) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# spell-checker:ignore humantime
|
||||
[package]
|
||||
name = "uu_date"
|
||||
version = "0.0.18"
|
||||
|
|
@ -16,8 +17,11 @@ path = "src/date.rs"
|
|||
|
||||
[dependencies]
|
||||
chrono = { workspace=true }
|
||||
#/ TODO: check if we can avoid chrono+time
|
||||
time = { workspace=true }
|
||||
clap = { workspace=true }
|
||||
uucore = { workspace=true }
|
||||
humantime_to_duration = { workspace=true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = { workspace=true }
|
||||
|
|
|
|||
87
src/uu/date/date-usage.md
Normal file
87
src/uu/date/date-usage.md
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# `date` usage
|
||||
|
||||
<!-- spell-checker:ignore (format) hhmm -->
|
||||
|
||||
FORMAT controls the output. Interpreted sequences are:
|
||||
|
||||
| Sequence | Description | Example |
|
||||
| -------- | -------------------------------------------------------------------- | ---------------------- |
|
||||
| %% | a literal % | % |
|
||||
| %a | locale's abbreviated weekday name | Sun |
|
||||
| %A | locale's full weekday name | Sunday |
|
||||
| %b | locale's abbreviated month name | Jan |
|
||||
| %B | locale's full month name | January |
|
||||
| %c | locale's date and time | Thu Mar 3 23:05:25 2005|
|
||||
| %C | century; like %Y, except omit last two digits | 20 |
|
||||
| %d | day of month | 01 |
|
||||
| %D | date; same as %m/%d/%y | 12/31/99 |
|
||||
| %e | day of month, space padded; same as %_d | 3 |
|
||||
| %F | full date; same as %Y-%m-%d | 2005-03-03 |
|
||||
| %g | last two digits of year of ISO week number (see %G) | 05 |
|
||||
| %G | year of ISO week number (see %V); normally useful only with %V | 2005 |
|
||||
| %h | same as %b | Jan |
|
||||
| %H | hour (00..23) | 23 |
|
||||
| %I | hour (01..12) | 11 |
|
||||
| %j | day of year (001..366) | 062 |
|
||||
| %k | hour, space padded ( 0..23); same as %_H | 3 |
|
||||
| %l | hour, space padded ( 1..12); same as %_I | 9 |
|
||||
| %m | month (01..12) | 03 |
|
||||
| %M | minute (00..59) | 30 |
|
||||
| %n | a newline | \n |
|
||||
| %N | nanoseconds (000000000..999999999) | 123456789 |
|
||||
| %p | locale's equivalent of either AM or PM; blank if not known | PM |
|
||||
| %P | like %p, but lower case | pm |
|
||||
| %q | quarter of year (1..4) | 1 |
|
||||
| %r | locale's 12-hour clock time | 11:11:04 PM |
|
||||
| %R | 24-hour hour and minute; same as %H:%M | 23:30 |
|
||||
| %s | seconds since 1970-01-01 00:00:00 UTC | 1615432800 |
|
||||
| %S | second (00..60) | 30 |
|
||||
| %t | a tab | \t |
|
||||
| %T | time; same as %H:%M:%S | 23:30:30 |
|
||||
| %u | day of week (1..7); 1 is Monday | 4 |
|
||||
| %U | week number of year, with Sunday as first day of week (00..53) | 10 |
|
||||
| %V | ISO week number, with Monday as first day of week (01..53) | 12 |
|
||||
| %w | day of week (0..6); 0 is Sunday | 4 |
|
||||
| %W | week number of year, with Monday as first day of week (00..53) | 11 |
|
||||
| %x | locale's date representation | 03/03/2005 |
|
||||
| %X | locale's time representation | 23:30:30 |
|
||||
| %y | last two digits of year (00..99) | 05 |
|
||||
| %Y | year | 2005 |
|
||||
| %z | +hhmm numeric time zone | -0400 |
|
||||
| %:z | +hh:mm numeric time zone | -04:00 |
|
||||
| %::z | +hh:mm:ss numeric time zone | -04:00:00 |
|
||||
| %:::z | numeric time zone with : to necessary precision | -04, +05:30 |
|
||||
| %Z | alphabetic time zone abbreviation | EDT |
|
||||
|
||||
By default, date pads numeric fields with zeroes.
|
||||
The following optional flags may follow '%':
|
||||
|
||||
* `-` (hyphen) do not pad the field
|
||||
* `_` (underscore) pad with spaces
|
||||
* `0` (zero) pad with zeros
|
||||
* `^` use upper case if possible
|
||||
* `#` use opposite case if possible
|
||||
|
||||
After any flags comes an optional field width, as a decimal number;
|
||||
then an optional modifier, which is either
|
||||
E to use the locale's alternate representations if available, or
|
||||
O to use the locale's alternate numeric symbols if available.
|
||||
|
||||
Examples:
|
||||
Convert seconds since the epoch (1970-01-01 UTC) to a date
|
||||
|
||||
```
|
||||
date --date='@2147483647'
|
||||
```
|
||||
|
||||
Show the time on the west coast of the US (use tzselect(1) to find TZ)
|
||||
|
||||
```
|
||||
TZ='America/Los_Angeles' date
|
||||
```
|
||||
|
||||
Show the local time for 9AM next Friday on the west coast of the US
|
||||
|
||||
```
|
||||
date --date='TZ="America/Los_Angeles" 09:00 next Fri'
|
||||
```
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
# `date` usage
|
||||
|
||||
<!-- spell-checker:ignore (format) hhmm -->
|
||||
|
||||
``` text
|
||||
FORMAT controls the output. Interpreted sequences are:
|
||||
|
||||
%% a literal %
|
||||
%a locale's abbreviated weekday name (e.g., Sun)
|
||||
%A locale's full weekday name (e.g., Sunday)
|
||||
%b locale's abbreviated month name (e.g., Jan)
|
||||
%B locale's full month name (e.g., January)
|
||||
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
|
||||
%C century; like %Y, except omit last two digits (e.g., 20)
|
||||
%d day of month (e.g., 01)
|
||||
%D date; same as %m/%d/%y
|
||||
%e day of month, space padded; same as %_d
|
||||
%F full date; same as %Y-%m-%d
|
||||
%g last two digits of year of ISO week number (see %G)
|
||||
%G year of ISO week number (see %V); normally useful only with %V
|
||||
%h same as %b
|
||||
%H hour (00..23)
|
||||
%I hour (01..12)
|
||||
%j day of year (001..366)
|
||||
%k hour, space padded ( 0..23); same as %_H
|
||||
%l hour, space padded ( 1..12); same as %_I
|
||||
%m month (01..12)
|
||||
%M minute (00..59)
|
||||
%n a newline
|
||||
%N nanoseconds (000000000..999999999)
|
||||
%p locale's equivalent of either AM or PM; blank if not known
|
||||
%P like %p, but lower case
|
||||
%q quarter of year (1..4)
|
||||
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
|
||||
%R 24-hour hour and minute; same as %H:%M
|
||||
%s seconds since 1970-01-01 00:00:00 UTC
|
||||
%S second (00..60)
|
||||
%t a tab
|
||||
%T time; same as %H:%M:%S
|
||||
%u day of week (1..7); 1 is Monday
|
||||
%U week number of year, with Sunday as first day of week (00..53)
|
||||
%V ISO week number, with Monday as first day of week (01..53)
|
||||
%w day of week (0..6); 0 is Sunday
|
||||
%W week number of year, with Monday as first day of week (00..53)
|
||||
%x locale's date representation (e.g., 12/31/99)
|
||||
%X locale's time representation (e.g., 23:13:48)
|
||||
%y last two digits of year (00..99)
|
||||
%Y year
|
||||
%z +hhmm numeric time zone (e.g., -0400)
|
||||
%:z +hh:mm numeric time zone (e.g., -04:00)
|
||||
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
|
||||
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)
|
||||
%Z alphabetic time zone abbreviation (e.g., EDT)
|
||||
|
||||
By default, date pads numeric fields with zeroes.
|
||||
The following optional flags may follow '%':
|
||||
|
||||
- (hyphen) do not pad the field
|
||||
_ (underscore) pad with spaces
|
||||
0 (zero) pad with zeros
|
||||
^ use upper case if possible
|
||||
# use opposite case if possible
|
||||
|
||||
After any flags comes an optional field width, as a decimal number;
|
||||
then an optional modifier, which is either
|
||||
E to use the locale's alternate representations if available, or
|
||||
O to use the locale's alternate numeric symbols if available.
|
||||
|
||||
Examples:
|
||||
Convert seconds since the epoch (1970-01-01 UTC) to a date
|
||||
$ date --date='@2147483647'
|
||||
|
||||
Show the time on the west coast of the US (use tzselect(1) to find TZ)
|
||||
$ TZ='America/Los_Angeles' date
|
||||
|
||||
Show the local time for 9AM next Friday on the west coast of the US
|
||||
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
|
||||
```
|
||||
|
|
@ -6,10 +6,10 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes
|
||||
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes humantime
|
||||
|
||||
use chrono::format::{Item, StrftimeItems};
|
||||
use chrono::{DateTime, FixedOffset, Local, Offset, Utc};
|
||||
use chrono::{DateTime, Duration as ChronoDuration, FixedOffset, Local, Offset, Utc};
|
||||
#[cfg(windows)]
|
||||
use chrono::{Datelike, Timelike};
|
||||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
|
|
@ -18,6 +18,7 @@ use libc::{clock_settime, timespec, CLOCK_REALTIME};
|
|||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::PathBuf;
|
||||
use time::Duration;
|
||||
use uucore::display::Quotable;
|
||||
#[cfg(not(any(target_os = "redox")))]
|
||||
use uucore::error::FromIo;
|
||||
|
|
@ -96,6 +97,7 @@ enum DateSource {
|
|||
Now,
|
||||
Custom(String),
|
||||
File(PathBuf),
|
||||
Human(Duration),
|
||||
}
|
||||
|
||||
enum Iso8601Format {
|
||||
|
|
@ -168,7 +170,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
};
|
||||
|
||||
let date_source = if let Some(date) = matches.get_one::<String>(OPT_DATE) {
|
||||
DateSource::Custom(date.into())
|
||||
if let Ok(duration) = humantime_to_duration::from_str(date.as_str()) {
|
||||
DateSource::Human(duration)
|
||||
} else {
|
||||
DateSource::Custom(date.into())
|
||||
}
|
||||
} else if let Some(file) = matches.get_one::<String>(OPT_FILE) {
|
||||
DateSource::File(file.into())
|
||||
} else {
|
||||
|
|
@ -219,6 +225,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let iter = std::iter::once(date);
|
||||
Box::new(iter)
|
||||
}
|
||||
DateSource::Human(ref input) => {
|
||||
// Get the current DateTime<FixedOffset> and convert the input time::Duration to chrono::Duration
|
||||
// for things like "1 year ago"
|
||||
let current_time = DateTime::<FixedOffset>::from(Local::now());
|
||||
let input_chrono = ChronoDuration::seconds(input.as_seconds_f32() as i64)
|
||||
+ ChronoDuration::nanoseconds(input.subsec_nanoseconds() as i64);
|
||||
let iter = std::iter::once(Ok(current_time + input_chrono));
|
||||
Box::new(iter)
|
||||
}
|
||||
DateSource::File(ref path) => {
|
||||
if path.is_dir() {
|
||||
return Err(USimpleError::new(
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ impl Params {
|
|||
.join(prefix_from_template)
|
||||
.display()
|
||||
.to_string();
|
||||
if options.treat_as_template && prefix.contains(MAIN_SEPARATOR) {
|
||||
if options.treat_as_template && prefix_from_template.contains(MAIN_SEPARATOR) {
|
||||
return Err(MkTempError::PrefixContainsDirSeparator(options.template));
|
||||
}
|
||||
if tmpdir.is_some() && Path::new(prefix_from_template).is_absolute() {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ pub enum MvError {
|
|||
DirectoryToNonDirectory(String),
|
||||
NonDirectoryToDirectory(String, String),
|
||||
NotADirectory(String),
|
||||
TargetNotADirectory(String),
|
||||
}
|
||||
|
||||
impl Error for MvError {}
|
||||
|
|
@ -34,7 +35,8 @@ impl Display for MvError {
|
|||
Self::NonDirectoryToDirectory(s, t) => {
|
||||
write!(f, "cannot overwrite non-directory {t} with directory {s}")
|
||||
}
|
||||
Self::NotADirectory(t) => write!(f, "target {t} is not a directory"),
|
||||
Self::NotADirectory(t) => write!(f, "target {t}: Not a directory"),
|
||||
Self::TargetNotADirectory(t) => write!(f, "target directory {t}: Not a directory"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,14 +108,22 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
let backup_suffix = backup_control::determine_backup_suffix(&matches);
|
||||
|
||||
let target_dir = matches
|
||||
.get_one::<OsString>(OPT_TARGET_DIRECTORY)
|
||||
.map(OsString::from);
|
||||
|
||||
if let Some(ref maybe_dir) = target_dir {
|
||||
if !Path::new(&maybe_dir).is_dir() {
|
||||
return Err(MvError::TargetNotADirectory(maybe_dir.quote().to_string()).into());
|
||||
}
|
||||
}
|
||||
|
||||
let behavior = Behavior {
|
||||
overwrite: overwrite_mode,
|
||||
backup: backup_mode,
|
||||
suffix: backup_suffix,
|
||||
update: update_mode,
|
||||
target_dir: matches
|
||||
.get_one::<OsString>(OPT_TARGET_DIRECTORY)
|
||||
.map(OsString::from),
|
||||
target_dir,
|
||||
no_target_dir: matches.get_flag(OPT_NO_TARGET_DIRECTORY),
|
||||
verbose: matches.get_flag(OPT_VERBOSE),
|
||||
strip_slashes: matches.get_flag(OPT_STRIP_TRAILING_SLASHES),
|
||||
|
|
@ -426,7 +434,12 @@ fn rename(
|
|||
}
|
||||
|
||||
match b.overwrite {
|
||||
OverwriteMode::NoClobber => return Ok(()),
|
||||
OverwriteMode::NoClobber => {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("not replacing {}", to.quote()),
|
||||
));
|
||||
}
|
||||
OverwriteMode::Interactive => {
|
||||
if !prompt_yes!("overwrite {}?", to.quote()) {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, ""));
|
||||
|
|
@ -458,12 +471,12 @@ fn rename(
|
|||
if b.verbose {
|
||||
let message = match backup_path {
|
||||
Some(path) => format!(
|
||||
"{} -> {} (backup: {})",
|
||||
"renamed {} -> {} (backup: {})",
|
||||
from.quote(),
|
||||
to.quote(),
|
||||
path.quote()
|
||||
),
|
||||
None => format!("{} -> {}", from.quote(), to.quote()),
|
||||
None => format!("renamed {} -> {}", from.quote(), to.quote()),
|
||||
};
|
||||
|
||||
match multi_progress {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use std::fmt::Display;
|
|||
use std::fs::File;
|
||||
use std::io::{stdin, stdout, BufRead, BufReader, Read, Write};
|
||||
use std::path::Path;
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("paste.md");
|
||||
|
|
@ -129,6 +129,16 @@ fn paste(
|
|||
files.push(file);
|
||||
}
|
||||
|
||||
if delimiters.ends_with('\\') && !delimiters.ends_with("\\\\") {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!(
|
||||
"delimiter list ends with an unescaped backslash: {}",
|
||||
delimiters
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
let delimiters: Vec<char> = unescape(delimiters).chars().collect();
|
||||
let mut delim_count = 0;
|
||||
let mut delim_length = 1;
|
||||
|
|
@ -222,10 +232,8 @@ fn paste(
|
|||
}
|
||||
|
||||
// Unescape all special characters
|
||||
// TODO: this will need work to conform to GNU implementation
|
||||
fn unescape(s: &str) -> String {
|
||||
s.replace("\\n", "\n")
|
||||
.replace("\\t", "\t")
|
||||
.replace("\\\\", "\\")
|
||||
.replace('\\', "")
|
||||
}
|
||||
|
|
|
|||
21
src/uu/sort/sort.md
Normal file
21
src/uu/sort/sort.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<!-- spell-checker:ignore MbdfhnRrV -->
|
||||
|
||||
# sort
|
||||
|
||||
```
|
||||
sort [OPTION]... [FILE]...
|
||||
```
|
||||
|
||||
Display sorted concatenation of all FILE(s). With no FILE, or when FILE is -, read standard input.
|
||||
|
||||
## After help
|
||||
|
||||
The key format is `FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS]`.
|
||||
|
||||
Fields by default are separated by the first whitespace after a non-whitespace character. Use `-t` to specify a custom separator.
|
||||
In the default case, whitespace is appended at the beginning of each field. Custom separators however are not included in fields.
|
||||
|
||||
`FIELD` and `CHAR` both start at 1 (i.e. they are 1-indexed). If there is no end specified after a comma, the end will be the end of the line.
|
||||
If `CHAR` is set 0, it means the end of the field. `CHAR` defaults to 1 for the start position and to 0 for the end position.
|
||||
|
||||
Valid options are: `MbdfhnRrV`. They override the global options for this key.
|
||||
|
|
@ -45,26 +45,15 @@ use std::str::Utf8Error;
|
|||
use unicode_width::UnicodeWidthStr;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, strip_errno, UError, UResult, USimpleError, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::parse_size::{ParseSizeError, Parser};
|
||||
use uucore::version_cmp::version_cmp;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
||||
use crate::tmp_dir::TmpDirWrapper;
|
||||
|
||||
const ABOUT: &str = "\
|
||||
Display sorted concatenation of all FILE(s). \
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
const USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
|
||||
const LONG_HELP_KEYS: &str = "The key format is FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS].
|
||||
|
||||
Fields by default are separated by the first whitespace after a non-whitespace character. Use -t to specify a custom separator.
|
||||
In the default case, whitespace is appended at the beginning of each field. Custom separators however are not included in fields.
|
||||
|
||||
FIELD and CHAR both start at 1 (i.e. they are 1-indexed). If there is no end specified after a comma, the end will be the end of the line.
|
||||
If CHAR is set 0, it means the end of the field. CHAR defaults to 1 for the start position and to 0 for the end position.
|
||||
|
||||
Valid options are: MbdfhnRrV. They override the global options for this key.";
|
||||
const ABOUT: &str = help_about!("sort.md");
|
||||
const USAGE: &str = help_usage!("sort.md");
|
||||
const AFTER_HELP: &str = help_section!("after help", "sort.md");
|
||||
|
||||
mod options {
|
||||
pub mod modes {
|
||||
|
|
@ -1292,7 +1281,7 @@ pub fn uu_app() -> Command {
|
|||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.after_help(LONG_HELP_KEYS)
|
||||
.after_help(AFTER_HELP)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.disable_help_flag(true)
|
||||
|
|
|
|||
13
src/uu/split/split.md
Normal file
13
src/uu/split/split.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!-- spell-checker:ignore PREFI -->
|
||||
|
||||
# split
|
||||
|
||||
```
|
||||
split [OPTION]... [INPUT [PREFIX]]
|
||||
```
|
||||
|
||||
Create output files containing consecutive or interleaved sections of input
|
||||
|
||||
## After Help
|
||||
|
||||
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is -, read standard input.
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) PREFIXaa PREFIXab nbbbb ncccc
|
||||
// spell-checker:ignore nbbbb ncccc
|
||||
|
||||
mod filenames;
|
||||
mod number;
|
||||
|
|
@ -23,9 +23,9 @@ use std::io::{stdin, BufRead, BufReader, BufWriter, ErrorKind, Read, Write};
|
|||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::parse_size::{parse_size, ParseSizeError};
|
||||
use uucore::uio_error;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
||||
static OPT_BYTES: &str = "bytes";
|
||||
static OPT_LINE_BYTES: &str = "line-bytes";
|
||||
|
|
@ -47,11 +47,9 @@ static OPT_ELIDE_EMPTY_FILES: &str = "elide-empty-files";
|
|||
static ARG_INPUT: &str = "input";
|
||||
static ARG_PREFIX: &str = "prefix";
|
||||
|
||||
const USAGE: &str = "{} [OPTION]... [INPUT [PREFIX]]";
|
||||
const AFTER_HELP: &str = "\
|
||||
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default \
|
||||
size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is \
|
||||
-, read standard input.";
|
||||
const ABOUT: &str = help_about!("split.md");
|
||||
const USAGE: &str = help_usage!("split.md");
|
||||
const AFTER_HELP: &str = help_section!("after help", "split.md");
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
|
|
@ -66,7 +64,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about("Create output files containing consecutive or interleaved sections of input")
|
||||
.about(ABOUT)
|
||||
.after_help(AFTER_HELP)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
|
|
|
|||
|
|
@ -17,23 +17,11 @@ use tempfile::tempdir;
|
|||
use tempfile::TempDir;
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::parse_size::parse_size;
|
||||
use uucore::{crash, format_usage};
|
||||
use uucore::{crash, format_usage, help_about, help_section, help_usage};
|
||||
|
||||
static ABOUT: &str =
|
||||
"Run COMMAND, with modified buffering operations for its standard streams.\n\n\
|
||||
Mandatory arguments to long options are mandatory for short options too.";
|
||||
const USAGE: &str = "{} OPTION... COMMAND";
|
||||
static LONG_HELP: &str = "If MODE is 'L' the corresponding stream will be line buffered.\n\
|
||||
This option is invalid with standard input.\n\n\
|
||||
If MODE is '0' the corresponding stream will be unbuffered.\n\n\
|
||||
Otherwise MODE is a number which may be followed by one of the following:\n\n\
|
||||
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\
|
||||
In this case the corresponding stream will be fully buffered with the buffer size set to \
|
||||
MODE bytes.\n\n\
|
||||
NOTE: If COMMAND adjusts the buffering of its standard streams ('tee' does for e.g.) then \
|
||||
that will override corresponding settings changed by 'stdbuf'.\n\
|
||||
Also some filters (like 'dd' and 'cat' etc.) don't use streams for I/O, \
|
||||
and are thus unaffected by 'stdbuf' settings.\n";
|
||||
const ABOUT: &str = help_about!("stdbuf.md");
|
||||
const USAGE: &str = help_usage!("stdbuf.md");
|
||||
const LONG_HELP: &str = help_section!("after help", "stdbuf.md");
|
||||
|
||||
mod options {
|
||||
pub const INPUT: &str = "input";
|
||||
|
|
|
|||
24
src/uu/stdbuf/stdbuf.md
Normal file
24
src/uu/stdbuf/stdbuf.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# stdbuf
|
||||
|
||||
```
|
||||
stdbuf [OPTION]... COMMAND
|
||||
```
|
||||
|
||||
Run `COMMAND`, with modified buffering operations for its standard streams.
|
||||
|
||||
Mandatory arguments to long options are mandatory for short options too.
|
||||
|
||||
## After Help
|
||||
|
||||
If `MODE` is 'L' the corresponding stream will be line buffered.
|
||||
This option is invalid with standard input.
|
||||
|
||||
If `MODE` is '0' the corresponding stream will be unbuffered.
|
||||
|
||||
Otherwise, `MODE` is a number which may be followed by one of the following:
|
||||
|
||||
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
|
||||
In this case the corresponding stream will be fully buffered with the buffer size set to `MODE` bytes.
|
||||
|
||||
NOTE: If `COMMAND` adjusts the buffering of its standard streams (`tee` does for e.g.) then that will override corresponding settings changed by `stdbuf`.
|
||||
Also some filters (like `dd` and `cat` etc.) don't use streams for I/O, and are thus unaffected by `stdbuf` settings.
|
||||
|
|
@ -18,7 +18,7 @@ use std::ops::ControlFlow;
|
|||
use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "freebsd",
|
||||
|
|
@ -31,11 +31,8 @@ use uucore::format_usage;
|
|||
use flags::BAUD_RATES;
|
||||
use flags::{CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS};
|
||||
|
||||
const USAGE: &str = "\
|
||||
{} [-F DEVICE | --file=DEVICE] [SETTING]...
|
||||
{} [-F DEVICE | --file=DEVICE] [-a|--all]
|
||||
{} [-F DEVICE | --file=DEVICE] [-g|--save]";
|
||||
const SUMMARY: &str = "Print or change terminal characteristics.";
|
||||
const USAGE: &str = help_usage!("stty.md");
|
||||
const SUMMARY: &str = help_about!("stty.md");
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Flag<T> {
|
||||
|
|
|
|||
9
src/uu/stty/stty.md
Normal file
9
src/uu/stty/stty.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# stty
|
||||
|
||||
```
|
||||
stty [-F DEVICE | --file=DEVICE] [SETTING]...
|
||||
stty [-F DEVICE | --file=DEVICE] [-a|--all]
|
||||
stty [-F DEVICE | --file=DEVICE] [-g|--save]
|
||||
```
|
||||
|
||||
Print or change terminal characteristics.
|
||||
|
|
@ -13,11 +13,10 @@ use std::io::{stdin, Read};
|
|||
use std::path::Path;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::{format_usage, show};
|
||||
use uucore::{format_usage, help_about, help_usage, show};
|
||||
|
||||
static USAGE: &str = "{} [OPTION]... [FILE]...";
|
||||
static ABOUT: &str = "Checksum and count the blocks in a file.\n\n\
|
||||
With no FILE, or when FILE is -, read standard input.";
|
||||
const USAGE: &str = help_usage!("sum.md");
|
||||
const ABOUT: &str = help_about!("sum.md");
|
||||
|
||||
// This can be replaced with usize::div_ceil once it is stabilized.
|
||||
// This implementation approach is optimized for when `b` is a constant,
|
||||
|
|
|
|||
9
src/uu/sum/sum.md
Normal file
9
src/uu/sum/sum.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# sum
|
||||
|
||||
```
|
||||
sum [OPTION]... [FILE]..."
|
||||
```
|
||||
|
||||
Checksum and count the blocks in a file.
|
||||
|
||||
With no FILE, or when FILE is -, read standard input.
|
||||
|
|
@ -19,10 +19,11 @@ use uucore::display::Quotable;
|
|||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use uucore::error::FromIo;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("sync.md");
|
||||
const USAGE: &str = help_usage!("sync.md");
|
||||
|
||||
static ABOUT: &str = "Synchronize cached writes to persistent storage";
|
||||
const USAGE: &str = "{} [OPTION]... FILE...";
|
||||
pub mod options {
|
||||
pub static FILE_SYSTEM: &str = "file-system";
|
||||
pub static DATA: &str = "data";
|
||||
|
|
|
|||
7
src/uu/sync/sync.md
Normal file
7
src/uu/sync/sync.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# sync
|
||||
|
||||
```
|
||||
sync [OPTION]... FILE...
|
||||
```
|
||||
|
||||
Synchronize cached writes to persistent storage
|
||||
|
|
@ -22,12 +22,12 @@ use uucore::process::ChildExt;
|
|||
use uucore::signals::enable_pipe_errors;
|
||||
|
||||
use uucore::{
|
||||
format_usage, show_error,
|
||||
format_usage, help_about, help_usage, show_error,
|
||||
signals::{signal_by_name_or_value, signal_name_by_value},
|
||||
};
|
||||
|
||||
static ABOUT: &str = "Start COMMAND, and kill it if still running after DURATION.";
|
||||
const USAGE: &str = "{} [OPTION] DURATION COMMAND...";
|
||||
const ABOUT: &str = help_about!("timeout.md");
|
||||
const USAGE: &str = help_usage!("timeout.md");
|
||||
|
||||
pub mod options {
|
||||
pub static FOREGROUND: &str = "foreground";
|
||||
|
|
|
|||
7
src/uu/timeout/timeout.md
Normal file
7
src/uu/timeout/timeout.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# timeout
|
||||
|
||||
```
|
||||
timeout [OPTION] DURATION COMMAND...
|
||||
```
|
||||
|
||||
Start `COMMAND`, and kill it if still running after `DURATION`.
|
||||
|
|
@ -13,17 +13,15 @@ use clap::{crate_version, Arg, ArgAction, Command};
|
|||
use nom::AsBytes;
|
||||
use operation::{translate_input, Sequence, SqueezeOperation, TranslateOperation};
|
||||
use std::io::{stdin, stdout, BufReader, BufWriter};
|
||||
use uucore::{format_usage, show};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, show};
|
||||
|
||||
use crate::operation::DeleteOperation;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||
|
||||
const ABOUT: &str = "Translate or delete characters";
|
||||
const USAGE: &str = "{} [OPTION]... SET1 [SET2]";
|
||||
const LONG_USAGE: &str = "\
|
||||
Translate, squeeze, and/or delete characters from standard input, \
|
||||
writing to standard output.";
|
||||
const ABOUT: &str = help_about!("tr.md");
|
||||
const AFTER_HELP: &str = help_section!("after help", "tr.md");
|
||||
const USAGE: &str = help_usage!("tr.md");
|
||||
|
||||
mod options {
|
||||
pub const COMPLEMENT: &str = "complement";
|
||||
|
|
@ -37,7 +35,7 @@ mod options {
|
|||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_lossy();
|
||||
|
||||
let matches = uu_app().after_help(LONG_USAGE).try_get_matches_from(args)?;
|
||||
let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;
|
||||
|
||||
let delete_flag = matches.get_flag(options::DELETE);
|
||||
let complement_flag = matches.get_flag(options::COMPLEMENT);
|
||||
|
|
|
|||
11
src/uu/tr/tr.md
Normal file
11
src/uu/tr/tr.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# tr
|
||||
|
||||
```
|
||||
tr [OPTION]... SET1 [SET2]
|
||||
```
|
||||
|
||||
Translate or delete characters
|
||||
|
||||
## After help
|
||||
|
||||
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
|
||||
Loading…
Add table
Add a link
Reference in a new issue