// GENERATED by bashkit-coreutils-port. DO NOT EDIT.
//
// Source: uutils/coreutils@39364b6 src/uu/truncate/
// Regenerate: cargo run -p bashkit-coreutils-port -- <UUTILS_DIR> truncate <REV>
//
// Original uutils licensed MIT; see THIRD_PARTY_LICENSES.
#![allow(unused_imports, dead_code)]
use clap::{Arg, ArgAction, Command, builder::ValueParser};
use std::ffi::OsString;
use std::ops::RangeInclusive;
use std::str::FromStr;
pub mod options {
pub static IO_BLOCKS: &str = "io-blocks";
pub static NO_CREATE: &str = "no-create";
pub static REFERENCE: &str = "reference";
pub static SIZE: &str = "size";
pub static ARG_FILES: &str = "files";
}
/// Vendored stand-in for `uucore::format_usage`.
///
/// Upstream wraps the usage line with stylized "Usage:" prefix logic
/// driven by uucore's locale stack. For our purposes the raw string
/// is enough; clap's `override_usage` accepts the literal as-is.
fn format_usage(s: &str) -> String {
s.to_string()
}
pub fn truncate_command() -> Command {
let cmd = Command::new("truncate")
.version(env!("CARGO_PKG_VERSION"))
.about(
::std::string::String::from(
"Shrink or extend the size of each file to the specified size.",
),
)
.override_usage(
format_usage(&::std::string::String::from("truncate [OPTION]... [FILE]...")),
)
.after_help(
::std::string::String::from(
"SIZE is an integer with an optional prefix and optional unit.\nThe available units (K, M, G, T, P, E, Z, and Y) use the following format:\n'KB' => 1000 (kilobytes)\n'K' => 1024 (kibibytes)\n'MB' => 1000*1000 (megabytes)\n'M' => 1024*1024 (mebibytes)\n'GB' => 1000*1000*1000 (gigabytes)\n'G' => 1024*1024*1024 (gibibytes)\nSIZE may also be prefixed by one of the following to adjust the size of each\nfile based on its current size:\n'+' => extend by\n'-' => reduce by\n'<' => at most\n'>' => at least\n'/' => round down to multiple of\n'%' => round up to multiple of",
),
)
.infer_long_args(true);
cmd.arg(
Arg::new(options::IO_BLOCKS)
.short('o')
.long(options::IO_BLOCKS)
.help(
::std::string::String::from(
"treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)",
),
)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::NO_CREATE)
.short('c')
.long(options::NO_CREATE)
.help(
::std::string::String::from("do not create files that do not exist"),
)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::REFERENCE)
.short('r')
.long(options::REFERENCE)
.required_unless_present(options::SIZE)
.help(
::std::string::String::from(
"base the size of each file on the size of RFILE",
),
)
.value_name("RFILE")
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::SIZE)
.short('s')
.long(options::SIZE)
.required_unless_present(options::REFERENCE)
.help(
::std::string::String::from(
"set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified",
),
)
.allow_hyphen_values(true)
.value_name("SIZE"),
)
.arg(
Arg::new(options::ARG_FILES)
.value_name("FILE")
.action(ArgAction::Append)
.required(true)
.value_hint(clap::ValueHint::FilePath)
.value_parser(clap::value_parser!(OsString)),
)
}