mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #1530 from @rivy (create publishable coreutils
)
Change ~ create a publishable version of `coreutils`
This commit is contained in:
commit
1c88bc8c45
445 changed files with 4461 additions and 3496 deletions
|
@ -1,5 +1,5 @@
|
||||||
# spell-checker:words POSIX SDK SDKs repo toolchain toolchains
|
# spell-checker:words POSIX SDK SDKs repo toolchain toolchains
|
||||||
# spell-checker:ignore ABI ARCH BACKTRACE BINDIR COMNTOOLS MINGW MINGWDIR MSVC MSYS USERPROFILE cl dllcrt findstr maint mkdir rustc rustlib rustup targetting uutils vcvarsall
|
# spell-checker:ignore ABI ARCH BACKTRACE BINDIR COMNTOOLS MINGW MINGWDIR MSVC MSYS USERPROFILE cl dllcrt findstr maint mkdir rustc rustlib rustup uutils vcvarsall
|
||||||
|
|
||||||
version: "{build} ~ {branch}"
|
version: "{build} ~ {branch}"
|
||||||
|
|
||||||
|
|
98
.github/workflows/CICD.yml
vendored
98
.github/workflows/CICD.yml
vendored
|
@ -4,13 +4,12 @@ name: CICD
|
||||||
# spell-checker:ignore (env/flags) Ccodegen Coverflow RUSTFLAGS
|
# spell-checker:ignore (env/flags) Ccodegen Coverflow RUSTFLAGS
|
||||||
# spell-checker:ignore (jargon) SHAs deps softprops toolchain
|
# spell-checker:ignore (jargon) SHAs deps softprops toolchain
|
||||||
# spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy
|
# spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy
|
||||||
# spell-checker:ignore (shell/tools) choco clippy dmake esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
|
# spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
|
||||||
# spell-checker:ignore (misc) alnum gnueabihf issuecomment maint nullglob onexitbegin onexitend uutils
|
# spell-checker:ignore (misc) aarch alnum armhf coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend uutils
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PROJECT_NAME: uutils
|
PROJECT_NAME: coreutils
|
||||||
PROJECT_DESC: "'Universal' (cross-platform) CLI utilities"
|
PROJECT_DESC: "Core universal (cross-platform) utilities"
|
||||||
PROJECT_AUTH: "uutils"
|
PROJECT_AUTH: "uutils"
|
||||||
RUST_MIN_SRV: "1.31.0" ## v1.31.0 == "Rust 2018" (2018-12-06)
|
RUST_MIN_SRV: "1.31.0" ## v1.31.0 == "Rust 2018" (2018-12-06)
|
||||||
RUST_COV_SRV: "2020-04-29" ## (~v1.45.0) supported rust version for code coverage; (date required/used by 'coverage') ## !maint: refactor when code coverage support is included in the stable channel
|
RUST_COV_SRV: "2020-04-29" ## (~v1.45.0) supported rust version for code coverage; (date required/used by 'coverage') ## !maint: refactor when code coverage support is included in the stable channel
|
||||||
|
@ -35,11 +34,6 @@ jobs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
## VARs setup
|
## VARs setup
|
||||||
# #maint: [rivy; 2020-02-08] 'windows-latest' `cargo fmt` is bugged for this project (see reasons @ GH:rust-lang/rustfmt #3324, #3590, #3688 ; waiting for repair)
|
|
||||||
JOB_DO_FORMAT_TESTING="true"
|
|
||||||
case '${{ matrix.job.os }}' in windows-latest) unset JOB_DO_FORMAT_TESTING ;; esac;
|
|
||||||
echo set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING:-<empty>/false}
|
|
||||||
echo ::set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING}
|
|
||||||
# target-specific options
|
# target-specific options
|
||||||
# * CARGO_FEATURES_OPTION
|
# * CARGO_FEATURES_OPTION
|
||||||
CARGO_FEATURES_OPTION='' ;
|
CARGO_FEATURES_OPTION='' ;
|
||||||
|
@ -54,14 +48,12 @@ jobs:
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
profile: minimal # minimal component installation (ie, no documentation)
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- name: "`fmt` testing"
|
- name: "`fmt` testing"
|
||||||
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# `fmt` testing
|
# `fmt` testing
|
||||||
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
||||||
S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; }
|
S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; }
|
||||||
- name: "`fmt` testing of tests"
|
- name: "`fmt` testing of tests"
|
||||||
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# `fmt` testing of tests
|
# `fmt` testing of tests
|
||||||
|
@ -130,7 +122,10 @@ jobs:
|
||||||
job:
|
job:
|
||||||
# { os, target, cargo-options, features, use-cross, toolchain }
|
# { os, target, cargo-options, features, use-cross, toolchain }
|
||||||
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross }
|
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross }
|
||||||
|
- { os: ubuntu-latest , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf , use-cross: use-cross }
|
||||||
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
|
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
|
||||||
|
# - { os: ubuntu-18.04 , target: i586-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross } ## note: older windows platform; not required, dev-FYI only
|
||||||
|
# - { os: ubuntu-18.04 , target: i586-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross } ## note: older windows platform; not required, dev-FYI only
|
||||||
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
|
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
|
||||||
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
|
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
|
||||||
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
|
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
|
||||||
|
@ -148,6 +143,7 @@ jobs:
|
||||||
## install/setup prerequisites
|
## install/setup prerequisites
|
||||||
case '${{ matrix.job.target }}' in
|
case '${{ matrix.job.target }}' in
|
||||||
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
||||||
|
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
|
||||||
esac
|
esac
|
||||||
- name: Initialize workflow variables
|
- name: Initialize workflow variables
|
||||||
id: vars
|
id: vars
|
||||||
|
@ -186,7 +182,14 @@ jobs:
|
||||||
echo ::set-output name=REF_TAG::${REF_TAG}
|
echo ::set-output name=REF_TAG::${REF_TAG}
|
||||||
echo ::set-output name=REF_SHAS::${REF_SHAS}
|
echo ::set-output name=REF_SHAS::${REF_SHAS}
|
||||||
# parse target
|
# parse target
|
||||||
unset TARGET_ARCH ; case '${{ matrix.job.target }}' in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
|
unset TARGET_ARCH
|
||||||
|
case '${{ matrix.job.target }}' in
|
||||||
|
aarch64-*) TARGET_ARCH=arm64 ;;
|
||||||
|
arm-*-*hf) TARGET_ARCH=armhf ;;
|
||||||
|
i586-*) TARGET_ARCH=i586 ;;
|
||||||
|
i686-*) TARGET_ARCH=i686 ;;
|
||||||
|
x86_64-*) TARGET_ARCH=x86_64 ;;
|
||||||
|
esac;
|
||||||
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
|
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
|
||||||
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
|
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
|
||||||
unset TARGET_OS ; case '${{ matrix.job.target }}' in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
|
unset TARGET_OS ; case '${{ matrix.job.target }}' in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
|
||||||
|
@ -203,9 +206,34 @@ jobs:
|
||||||
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
|
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
|
||||||
echo ::set-output name=PKG_NAME::${PKG_NAME}
|
echo ::set-output name=PKG_NAME::${PKG_NAME}
|
||||||
# deployable tag? (ie, leading "vM" or "M"; M == version number)
|
# deployable tag? (ie, leading "vM" or "M"; M == version number)
|
||||||
unset DEPLOYABLE ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOYABLE='true' ; fi
|
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
|
||||||
echo set-output name=DEPLOYABLE::${DEPLOYABLE:-<empty>/false}
|
echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
|
||||||
echo ::set-output name=DEPLOYABLE::${DEPLOYABLE}
|
echo ::set-output name=DEPLOY::${DEPLOY}
|
||||||
|
# DPKG architecture?
|
||||||
|
unset DPKG_ARCH
|
||||||
|
case ${{ matrix.job.target }} in
|
||||||
|
x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
|
||||||
|
*-linux-*) DPKG_ARCH=${TARGET_ARCH} ;;
|
||||||
|
esac
|
||||||
|
echo set-output name=DPKG_ARCH::${DPKG_ARCH}
|
||||||
|
echo ::set-output name=DPKG_ARCH::${DPKG_ARCH}
|
||||||
|
# DPKG version?
|
||||||
|
unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi
|
||||||
|
echo set-output name=DPKG_VERSION::${DPKG_VERSION}
|
||||||
|
echo ::set-output name=DPKG_VERSION::${DPKG_VERSION}
|
||||||
|
# DPKG base name/conflicts?
|
||||||
|
DPKG_BASENAME=${PROJECT_NAME}
|
||||||
|
DPKG_CONFLICTS=${PROJECT_NAME}-musl
|
||||||
|
case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${PROJECT_NAME}-musl ; DPKG_CONFLICTS=${PROJECT_NAME} ;; esac;
|
||||||
|
echo set-output name=DPKG_BASENAME::${DPKG_BASENAME}
|
||||||
|
echo set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
|
||||||
|
echo ::set-output name=DPKG_BASENAME::${DPKG_BASENAME}
|
||||||
|
echo ::set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
|
||||||
|
# DPKG name
|
||||||
|
unset DPKG_NAME;
|
||||||
|
if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi
|
||||||
|
echo set-output name=DPKG_NAME::${DPKG_NAME}
|
||||||
|
echo ::set-output name=DPKG_NAME::${DPKG_NAME}
|
||||||
# target-specific options
|
# target-specific options
|
||||||
# * CARGO_FEATURES_OPTION
|
# * CARGO_FEATURES_OPTION
|
||||||
CARGO_FEATURES_OPTION='' ;
|
CARGO_FEATURES_OPTION='' ;
|
||||||
|
@ -216,18 +244,17 @@ jobs:
|
||||||
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
|
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
|
||||||
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
|
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
|
||||||
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
|
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
|
||||||
# # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
|
# * test only library and/or binaries for arm-type targets
|
||||||
JOB_DO_TESTING="true"
|
unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in aarch64-* | arm-*) CARGO_TEST_OPTIONS="--bins" ;; esac;
|
||||||
case '${{ matrix.job.target }}' in arm-*) unset JOB_DO_TESTING ;; esac;
|
|
||||||
echo set-output name=JOB_DO_TESTING::${JOB_DO_TESTING:-<empty>/false}
|
|
||||||
echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
|
|
||||||
# # * test only binary for arm-type targets
|
|
||||||
unset CARGO_TEST_OPTIONS
|
|
||||||
unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in arm-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
|
|
||||||
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
||||||
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
||||||
# * strip executable?
|
# * executable for `strip`?
|
||||||
STRIP="strip" ; case '${{ matrix.job.target }}' in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
|
STRIP="strip"
|
||||||
|
case ${{ matrix.job.target }} in
|
||||||
|
aarch64-*-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
|
||||||
|
arm-*-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;;
|
||||||
|
*-pc-windows-msvc) STRIP="" ;;
|
||||||
|
esac;
|
||||||
echo set-output name=STRIP::${STRIP:-<empty>/false}
|
echo set-output name=STRIP::${STRIP:-<empty>/false}
|
||||||
echo ::set-output name=STRIP::${STRIP}
|
echo ::set-output name=STRIP::${STRIP}
|
||||||
- name: Create all needed build/work directories
|
- name: Create all needed build/work directories
|
||||||
|
@ -236,6 +263,7 @@ jobs:
|
||||||
## create build/work space
|
## create build/work space
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}'
|
mkdir -p '${{ steps.vars.outputs.STAGING }}'
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
|
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
|
||||||
|
mkdir -p '${{ steps.vars.outputs.STAGING }}/dpkg'
|
||||||
- name: rust toolchain ~ install
|
- name: rust toolchain ~ install
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
@ -307,12 +335,28 @@ jobs:
|
||||||
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
|
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
|
||||||
esac
|
esac
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
# dpkg
|
||||||
|
if [ -n "${{ steps.vars.outputs.DPKG_NAME }}" ]; then
|
||||||
|
DPKG_DIR="${{ steps.vars.outputs.STAGING }}/dpkg"
|
||||||
|
# binary
|
||||||
|
install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}"
|
||||||
|
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
|
||||||
|
# README and LICENSE
|
||||||
|
(shopt -s nullglob; for f in [R]"EADME"{,.*}; do install -Dm644 "$f" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/$f" ; done)
|
||||||
|
(shopt -s nullglob; for f in [L]"ICENSE"{-*,}{,.*}; do install -Dm644 "$f" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/$f" ; done)
|
||||||
|
# control file
|
||||||
|
mkdir -p "${DPKG_DIR}/DEBIAN"
|
||||||
|
printf "Package: ${{ steps.vars.outputs.DPKG_BASENAME }}\nVersion: ${{ steps.vars.outputs.DPKG_VERSION }}\nSection: utils\nPriority: optional\nMaintainer: ${{ env.PROJECT_AUTH }}\nArchitecture: ${{ steps.vars.outputs.DPKG_ARCH }}\nProvides: ${{ env.PROJECT_NAME }}\nConflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}\nDescription: ${{ env.PROJECT_DESC }}\n" > "${DPKG_DIR}/DEBIAN/control"
|
||||||
|
# build dpkg
|
||||||
|
fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
|
||||||
|
fi
|
||||||
- name: Publish
|
- name: Publish
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: steps.vars.outputs.DEPLOYABLE
|
if: steps.vars.outputs.DEPLOY
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
|
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
|
||||||
|
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|
296
.vscode/cSpell.json
vendored
Normal file
296
.vscode/cSpell.json
vendored
Normal file
|
@ -0,0 +1,296 @@
|
||||||
|
// `cspell` settings
|
||||||
|
{
|
||||||
|
"version": "0.1", // Version of the setting file. Always 0.1
|
||||||
|
"language": "en", // language - current active spelling language
|
||||||
|
// ignoreWords
|
||||||
|
"ignoreWords": [
|
||||||
|
// abbrev/acronyms
|
||||||
|
"Cygwin",
|
||||||
|
"FreeBSD",
|
||||||
|
"Gmail",
|
||||||
|
"Irix",
|
||||||
|
"MacOS",
|
||||||
|
"MinGW",
|
||||||
|
"Minix",
|
||||||
|
"MS-DOS",
|
||||||
|
"MSDOS",
|
||||||
|
"NetBSD",
|
||||||
|
"Novell",
|
||||||
|
"OpenBSD",
|
||||||
|
"POSIX",
|
||||||
|
"SELinux",
|
||||||
|
"Solaris",
|
||||||
|
"Xenix",
|
||||||
|
"flac",
|
||||||
|
"lzma",
|
||||||
|
// crates
|
||||||
|
"byteorder",
|
||||||
|
"chrono",
|
||||||
|
"filetime",
|
||||||
|
"formatteriteminfo",
|
||||||
|
"getopts",
|
||||||
|
"itertools",
|
||||||
|
"multifilereader",
|
||||||
|
"onig",
|
||||||
|
"peekreader",
|
||||||
|
"termion",
|
||||||
|
"termios",
|
||||||
|
"termsize",
|
||||||
|
"termwidth",
|
||||||
|
"textwrap",
|
||||||
|
"walkdir",
|
||||||
|
"winapi",
|
||||||
|
"xattr",
|
||||||
|
// jargon
|
||||||
|
"AST", // abstract syntax tree
|
||||||
|
"CPU",
|
||||||
|
"CPUs",
|
||||||
|
"FIFO",
|
||||||
|
"FIFOs",
|
||||||
|
"FQDN", // fully qualified domain name
|
||||||
|
"GID", // group ID
|
||||||
|
"GIDs",
|
||||||
|
"POSIXLY",
|
||||||
|
"RNG", // random number generator
|
||||||
|
"RNGs",
|
||||||
|
"UID", // user ID
|
||||||
|
"UIDs",
|
||||||
|
"UUID", // universally unique identifier
|
||||||
|
"arity",
|
||||||
|
"bitmask",
|
||||||
|
"canonicalization",
|
||||||
|
"canonicalize",
|
||||||
|
"colorizable",
|
||||||
|
"colorize",
|
||||||
|
"consts",
|
||||||
|
"dedup",
|
||||||
|
"deque",
|
||||||
|
"dequeue",
|
||||||
|
"enqueue",
|
||||||
|
"executable",
|
||||||
|
"executables",
|
||||||
|
"gibibytes",
|
||||||
|
"hardlink",
|
||||||
|
"hardlinks",
|
||||||
|
"hashsums",
|
||||||
|
"kibibytes",
|
||||||
|
"mebibytes",
|
||||||
|
"mergeable",
|
||||||
|
"multibyte",
|
||||||
|
"nonportable",
|
||||||
|
"peekable",
|
||||||
|
"precompiled",
|
||||||
|
"precompute",
|
||||||
|
"preload",
|
||||||
|
"prepend",
|
||||||
|
"prepended",
|
||||||
|
"primality",
|
||||||
|
"pseudoprime",
|
||||||
|
"pseudoprimes",
|
||||||
|
"readonly",
|
||||||
|
"seedable",
|
||||||
|
"semver",
|
||||||
|
"symlink",
|
||||||
|
"symlinks",
|
||||||
|
"syscall",
|
||||||
|
"toekenize",
|
||||||
|
"unbuffered",
|
||||||
|
"unportable",
|
||||||
|
"whitespace",
|
||||||
|
// names
|
||||||
|
"Akira Hayakawa", "Akira", "Hayakawa",
|
||||||
|
"Alan Andrade", "Alan", "Andrade",
|
||||||
|
"Alex Lyon", "Alex", "Lyon",
|
||||||
|
"Alexander Batischev", "Alexander", "Batischev",
|
||||||
|
"Aleksander Bielawski", "Aleksander", "Bielawski",
|
||||||
|
"Alexander Fomin", "Alexander", "Fomin",
|
||||||
|
"Anthony Deschamps", "Anthony", "Deschamps",
|
||||||
|
"Ben Eills", "Ben", "Eills",
|
||||||
|
"Ben Hirsch", "Ben", "Hirsch",
|
||||||
|
"Benoit Benedetti", "Benoit", "Benedetti",
|
||||||
|
"Boden Garman", "Boden", "Garman",
|
||||||
|
"Chirag B Jadwani", "Chirag", "Jadwani",
|
||||||
|
"Derek Chiang", "Derek", "Chiang",
|
||||||
|
"Dorota Kapturkiewicz", "Dorota", "Kapturkiewicz",
|
||||||
|
"Evgeniy Klyuchikov", "Evgeniy", "Klyuchikov",
|
||||||
|
"Fangxu Hu", "Fangxu", "Hu",
|
||||||
|
"Gil Cottle", "Gil", "Cottle",
|
||||||
|
"Haitao Li", "Haitao", "Li",
|
||||||
|
"Inokentiy Babushkin", "Inokentiy", "Babushkin",
|
||||||
|
"Joao Oliveira", "Joao", "Oliveira",
|
||||||
|
"Jeremiah Peschka", "Jeremiah", "Peschka",
|
||||||
|
"Jian Zeng", "Jian", "Zeng",
|
||||||
|
"Jimmy Lu", "Jimmy", "Lu",
|
||||||
|
"Jordi Boggiano", "Jordi", "Boggiano",
|
||||||
|
"Jordy Dickinson", "Jordy", "Dickinson",
|
||||||
|
"Joseph Crail", "Joseph", "Crail",
|
||||||
|
"Joshua S Miller", "Joshua", "Miller",
|
||||||
|
"KokaKiwi",
|
||||||
|
"Konstantin Pospelov", "Konstantin", "Pospelov",
|
||||||
|
"Mahkoh",
|
||||||
|
"Maciej Dziardziel", "Maciej", "Dziardziel",
|
||||||
|
"Michael Gehring", "Michael", "Gehring",
|
||||||
|
"Martin Kysel", "Martin", "Kysel",
|
||||||
|
"Morten Olsen Lysgaard", "Morten", "Olsen", "Lysgaard",
|
||||||
|
"Nicholas Juszczak", "Nicholas", "Juszczak",
|
||||||
|
"Nick Platt", "Nick", "Platt",
|
||||||
|
"Orvar Segerström", "Orvar", "Segerström",
|
||||||
|
"Peter Atashian", "Peter", "Atashian",
|
||||||
|
"Rolf Morel", "Rolf", "Morel",
|
||||||
|
"Roman Gafiyatullin", "Roman", "Gafiyatullin",
|
||||||
|
"Roy Ivy III", "Roy", "Ivy", "III",
|
||||||
|
"Sergey 'Shnatsel' Davidoff", "Sergey", "Shnatsel", "Davidoff",
|
||||||
|
"Sokovikov Evgeniy", "Sokovikov", "Evgeniy",
|
||||||
|
"Sunrin SHIMURA", "Sunrin", "SHIMURA",
|
||||||
|
"Smigle00", "Smigle",
|
||||||
|
"Sylvestre Ledru", "Sylvestre", "Ledru",
|
||||||
|
"Tobias Bohumir Schottdorf", "Tobias", "Bohumir", "Schottdorf",
|
||||||
|
"Virgile Andreani", "Virgile", "Andreani",
|
||||||
|
"Vsevolod Velichko", "Vsevolod", "Velichko",
|
||||||
|
"Wiktor Kuropatwa", "Wiktor", "Kuropatwa",
|
||||||
|
"Yury Krivopalov", "Yury", "Krivopalov",
|
||||||
|
"anonymousknight",
|
||||||
|
"kwantam",
|
||||||
|
// rust
|
||||||
|
"clippy",
|
||||||
|
"concat",
|
||||||
|
"powi",
|
||||||
|
"repr",
|
||||||
|
"rfind",
|
||||||
|
"rustc",
|
||||||
|
"rustfmt",
|
||||||
|
"substr",
|
||||||
|
"splitn",
|
||||||
|
// shell
|
||||||
|
"passwd",
|
||||||
|
"tcsh",
|
||||||
|
// tags
|
||||||
|
"Maint",
|
||||||
|
// uutils
|
||||||
|
"chgrp",
|
||||||
|
"chmod",
|
||||||
|
"chown",
|
||||||
|
"chroot",
|
||||||
|
"cksum",
|
||||||
|
"dircolors",
|
||||||
|
"hashsum",
|
||||||
|
"hostid",
|
||||||
|
"logname",
|
||||||
|
"mkdir",
|
||||||
|
"mkfifo",
|
||||||
|
"mknod",
|
||||||
|
"mktemp",
|
||||||
|
"nohup",
|
||||||
|
"nproc",
|
||||||
|
"numfmt",
|
||||||
|
"pathchk",
|
||||||
|
"printenv",
|
||||||
|
"printf",
|
||||||
|
"readlink",
|
||||||
|
"realpath",
|
||||||
|
"relpath",
|
||||||
|
"rmdir",
|
||||||
|
"shuf",
|
||||||
|
"stdbuf",
|
||||||
|
"tsort",
|
||||||
|
"uname",
|
||||||
|
"unexpand",
|
||||||
|
"whoami",
|
||||||
|
// vars/libc
|
||||||
|
"FILENO",
|
||||||
|
"HOSTSIZE",
|
||||||
|
"IDSIZE",
|
||||||
|
"IRGRP",
|
||||||
|
"IROTH",
|
||||||
|
"IRUSR",
|
||||||
|
"ISGID",
|
||||||
|
"ISUID",
|
||||||
|
"ISVTX",
|
||||||
|
"IWGRP",
|
||||||
|
"IWOTH",
|
||||||
|
"IWUSR",
|
||||||
|
"IXGRP",
|
||||||
|
"IXOTH",
|
||||||
|
"IXUSR",
|
||||||
|
"LINESIZE",
|
||||||
|
"NAMESIZE",
|
||||||
|
"USERSIZE",
|
||||||
|
"addrinfo",
|
||||||
|
"addrlen",
|
||||||
|
"canonname",
|
||||||
|
"chroot",
|
||||||
|
"freeaddrinfo",
|
||||||
|
"getaddrinfo",
|
||||||
|
"getegid",
|
||||||
|
"geteuid",
|
||||||
|
"getgid",
|
||||||
|
"getgrgid",
|
||||||
|
"getgrnam",
|
||||||
|
"getgrouplist",
|
||||||
|
"getgroups",
|
||||||
|
"getpwnam",
|
||||||
|
"getpwuid",
|
||||||
|
"getuid",
|
||||||
|
"inode",
|
||||||
|
"isatty",
|
||||||
|
"lchown",
|
||||||
|
"setgid",
|
||||||
|
"setgroups",
|
||||||
|
"setuid",
|
||||||
|
"socktype",
|
||||||
|
"umask",
|
||||||
|
"waitpid",
|
||||||
|
// vars/signals
|
||||||
|
"SIGPIPE",
|
||||||
|
// vars/sync
|
||||||
|
"Condvar",
|
||||||
|
// vars/time
|
||||||
|
"Timespec",
|
||||||
|
"nsec",
|
||||||
|
"nsecs",
|
||||||
|
"strftime",
|
||||||
|
"usec",
|
||||||
|
"usecs",
|
||||||
|
// vars/utmpx
|
||||||
|
"endutxent",
|
||||||
|
"getutxent",
|
||||||
|
"getutxid",
|
||||||
|
"getutxline",
|
||||||
|
"pututxline",
|
||||||
|
"setutxent",
|
||||||
|
"utmp",
|
||||||
|
"utmpx",
|
||||||
|
"utmpxname",
|
||||||
|
// vars/winapi
|
||||||
|
"errhandlingapi",
|
||||||
|
"fileapi",
|
||||||
|
"handleapi",
|
||||||
|
"minwindef",
|
||||||
|
"processthreadsapi",
|
||||||
|
"synchapi",
|
||||||
|
"winbase",
|
||||||
|
"winerror",
|
||||||
|
"winnt",
|
||||||
|
"winsock",
|
||||||
|
"DWORD",
|
||||||
|
"LPWSTR",
|
||||||
|
"WCHAR",
|
||||||
|
// uucore
|
||||||
|
"optflag",
|
||||||
|
"optflagmulti",
|
||||||
|
"optflagopt",
|
||||||
|
"optmulti",
|
||||||
|
"optopt",
|
||||||
|
// uutils
|
||||||
|
"coreopts",
|
||||||
|
"coreutils",
|
||||||
|
"libc",
|
||||||
|
"musl",
|
||||||
|
"utmpx",
|
||||||
|
"uucore",
|
||||||
|
"uumain",
|
||||||
|
"uutils"
|
||||||
|
],
|
||||||
|
// words - list of words to be always considered correct
|
||||||
|
"words": []
|
||||||
|
}
|
2710
Cargo.lock
generated
2710
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
226
Cargo.toml
226
Cargo.toml
|
@ -1,13 +1,20 @@
|
||||||
# uutils / coreutils
|
# coreutils (uutils)
|
||||||
# * see the repository LICENSE, README, and CONTRIBUTING files for more information
|
# * see the repository LICENSE, README, and CONTRIBUTING files for more information
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "uutils"
|
name = "coreutils"
|
||||||
description = "uutils ~ universal (as in cross-platform) CLI utils, written in Rust"
|
version = "0.0.1" # "0.0.1.1"
|
||||||
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
repository = "https://github.com/uutils/coreutils"
|
repository = "https://github.com/uutils/coreutils"
|
||||||
version = "0.0.1"
|
readme = "README.md"
|
||||||
authors = []
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
autotests = false
|
autotests = false
|
||||||
|
|
||||||
|
@ -210,111 +217,118 @@ feat_os_windows_legacy = [
|
||||||
"touch",
|
"touch",
|
||||||
"whoami",
|
"whoami",
|
||||||
]
|
]
|
||||||
|
##
|
||||||
|
# * bypass/override ~ translate 'test' feature name to avoid dependency collision with rust core 'test' crate (o/w surfaces as compiler errors during testing)
|
||||||
|
test = [ "uu_test" ]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = { version="1.3" }
|
lazy_static = { version="1.3" }
|
||||||
textwrap = { version="=0.11.0", features=["term_size"] } # !maint: [2020-05-10; rivy] unstable crate using undocumented features; pinned currently, will review
|
textwrap = { version="=0.11.0", features=["term_size"] } # !maint: [2020-05-10; rivy] unstable crate using undocumented features; pinned currently, will review
|
||||||
uucore = { version="0.0.2" }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="master" }
|
||||||
# * uutils
|
# * uutils
|
||||||
arch = { optional=true, path="src/uu/arch" }
|
uu_test = { optional=true, version="0.0.1", package="uu_test", path="src/uu/test" }
|
||||||
base32 = { optional=true, path="src/uu/base32" }
|
|
||||||
base64 = { optional=true, path="src/uu/base64" }
|
|
||||||
basename = { optional=true, path="src/uu/basename" }
|
|
||||||
cat = { optional=true, path="src/uu/cat" }
|
|
||||||
chgrp = { optional=true, path="src/uu/chgrp" }
|
|
||||||
chmod = { optional=true, path="src/uu/chmod" }
|
|
||||||
chown = { optional=true, path="src/uu/chown" }
|
|
||||||
chroot = { optional=true, path="src/uu/chroot" }
|
|
||||||
cksum = { optional=true, path="src/uu/cksum" }
|
|
||||||
comm = { optional=true, path="src/uu/comm" }
|
|
||||||
cp = { optional=true, path="src/uu/cp" }
|
|
||||||
cut = { optional=true, path="src/uu/cut" }
|
|
||||||
date = { optional=true, path="src/uu/date" }
|
|
||||||
df = { optional=true, path="src/uu/df" }
|
|
||||||
dircolors= { optional=true, path="src/uu/dircolors" }
|
|
||||||
dirname = { optional=true, path="src/uu/dirname" }
|
|
||||||
du = { optional=true, path="src/uu/du" }
|
|
||||||
echo = { optional=true, path="src/uu/echo" }
|
|
||||||
env = { optional=true, path="src/uu/env" }
|
|
||||||
expand = { optional=true, path="src/uu/expand" }
|
|
||||||
expr = { optional=true, path="src/uu/expr" }
|
|
||||||
factor = { optional=true, path="src/uu/factor" }
|
|
||||||
false = { optional=true, path="src/uu/false" }
|
|
||||||
fmt = { optional=true, path="src/uu/fmt" }
|
|
||||||
fold = { optional=true, path="src/uu/fold" }
|
|
||||||
groups = { optional=true, path="src/uu/groups" }
|
|
||||||
hashsum = { optional=true, path="src/uu/hashsum" }
|
|
||||||
head = { optional=true, path="src/uu/head" }
|
|
||||||
hostid = { optional=true, path="src/uu/hostid" }
|
|
||||||
hostname = { optional=true, path="src/uu/hostname" }
|
|
||||||
id = { optional=true, path="src/uu/id" }
|
|
||||||
install = { optional=true, path="src/uu/install" }
|
|
||||||
join = { optional=true, path="src/uu/join" }
|
|
||||||
kill = { optional=true, path="src/uu/kill" }
|
|
||||||
link = { optional=true, path="src/uu/link" }
|
|
||||||
ln = { optional=true, path="src/uu/ln" }
|
|
||||||
ls = { optional=true, path="src/uu/ls" }
|
|
||||||
logname = { optional=true, path="src/uu/logname" }
|
|
||||||
mkdir = { optional=true, path="src/uu/mkdir" }
|
|
||||||
mkfifo = { optional=true, path="src/uu/mkfifo" }
|
|
||||||
mknod = { optional=true, path="src/uu/mknod" }
|
|
||||||
mktemp = { optional=true, path="src/uu/mktemp" }
|
|
||||||
more = { optional=true, path="src/uu/more" }
|
|
||||||
mv = { optional=true, path="src/uu/mv" }
|
|
||||||
nice = { optional=true, path="src/uu/nice" }
|
|
||||||
nl = { optional=true, path="src/uu/nl" }
|
|
||||||
nohup = { optional=true, path="src/uu/nohup" }
|
|
||||||
nproc = { optional=true, path="src/uu/nproc" }
|
|
||||||
numfmt = { optional=true, path="src/uu/numfmt" }
|
|
||||||
od = { optional=true, path="src/uu/od" }
|
|
||||||
paste = { optional=true, path="src/uu/paste" }
|
|
||||||
pathchk = { optional=true, path="src/uu/pathchk" }
|
|
||||||
pinky = { optional=true, path="src/uu/pinky" }
|
|
||||||
printenv = { optional=true, path="src/uu/printenv" }
|
|
||||||
printf = { optional=true, path="src/uu/printf" }
|
|
||||||
ptx = { optional=true, path="src/uu/ptx" }
|
|
||||||
pwd = { optional=true, path="src/uu/pwd" }
|
|
||||||
readlink = { optional=true, path="src/uu/readlink" }
|
|
||||||
realpath = { optional=true, path="src/uu/realpath" }
|
|
||||||
relpath = { optional=true, path="src/uu/relpath" }
|
|
||||||
rm = { optional=true, path="src/uu/rm" }
|
|
||||||
rmdir = { optional=true, path="src/uu/rmdir" }
|
|
||||||
seq = { optional=true, path="src/uu/seq" }
|
|
||||||
shred = { optional=true, path="src/uu/shred" }
|
|
||||||
shuf = { optional=true, path="src/uu/shuf" }
|
|
||||||
sleep = { optional=true, path="src/uu/sleep" }
|
|
||||||
sort = { optional=true, path="src/uu/sort" }
|
|
||||||
split = { optional=true, path="src/uu/split" }
|
|
||||||
stat = { optional=true, path="src/uu/stat" }
|
|
||||||
stdbuf = { optional=true, path="src/uu/stdbuf" }
|
|
||||||
sum = { optional=true, path="src/uu/sum" }
|
|
||||||
sync = { optional=true, path="src/uu/sync" }
|
|
||||||
tac = { optional=true, path="src/uu/tac" }
|
|
||||||
tail = { optional=true, path="src/uu/tail" }
|
|
||||||
tee = { optional=true, path="src/uu/tee" }
|
|
||||||
test = { optional=true, path="src/uu/test" }
|
|
||||||
timeout = { optional=true, path="src/uu/timeout" }
|
|
||||||
touch = { optional=true, path="src/uu/touch" }
|
|
||||||
tr = { optional=true, path="src/uu/tr" }
|
|
||||||
true = { optional=true, path="src/uu/true" }
|
|
||||||
truncate = { optional=true, path="src/uu/truncate" }
|
|
||||||
tsort = { optional=true, path="src/uu/tsort" }
|
|
||||||
tty = { optional=true, path="src/uu/tty" }
|
|
||||||
uname = { optional=true, path="src/uu/uname" }
|
|
||||||
unexpand = { optional=true, path="src/uu/unexpand" }
|
|
||||||
uniq = { optional=true, path="src/uu/uniq" }
|
|
||||||
unlink = { optional=true, path="src/uu/unlink" }
|
|
||||||
uptime = { optional=true, path="src/uu/uptime" }
|
|
||||||
users = { optional=true, path="src/uu/users" }
|
|
||||||
wc = { optional=true, path="src/uu/wc" }
|
|
||||||
who = { optional=true, path="src/uu/who" }
|
|
||||||
whoami = { optional=true, path="src/uu/whoami" }
|
|
||||||
yes = { optional=true, path="src/uu/yes" }
|
|
||||||
#
|
#
|
||||||
# * transitive dependency via 'failure'; pin to <= v0.3.30 to avoid increasing MinSRV to v1.33.0
|
arch = { optional=true, version="0.0.1", package="uu_arch", path="src/uu/arch" }
|
||||||
_backtrace = { version=">= 0.3.3, <= 0.3.30", package="backtrace" }
|
base32 = { optional=true, version="0.0.1", package="uu_base32", path="src/uu/base32" }
|
||||||
|
base64 = { optional=true, version="0.0.1", package="uu_base64", path="src/uu/base64" }
|
||||||
|
basename = { optional=true, version="0.0.1", package="uu_basename", path="src/uu/basename" }
|
||||||
|
cat = { optional=true, version="0.0.1", package="uu_cat", path="src/uu/cat" }
|
||||||
|
chgrp = { optional=true, version="0.0.1", package="uu_chgrp", path="src/uu/chgrp" }
|
||||||
|
chmod = { optional=true, version="0.0.1", package="uu_chmod", path="src/uu/chmod" }
|
||||||
|
chown = { optional=true, version="0.0.1", package="uu_chown", path="src/uu/chown" }
|
||||||
|
chroot = { optional=true, version="0.0.1", package="uu_chroot", path="src/uu/chroot" }
|
||||||
|
cksum = { optional=true, version="0.0.1", package="uu_cksum", path="src/uu/cksum" }
|
||||||
|
comm = { optional=true, version="0.0.1", package="uu_comm", path="src/uu/comm" }
|
||||||
|
cp = { optional=true, version="0.0.1", package="uu_cp", path="src/uu/cp" }
|
||||||
|
cut = { optional=true, version="0.0.1", package="uu_cut", path="src/uu/cut" }
|
||||||
|
date = { optional=true, version="0.0.1", package="uu_date", path="src/uu/date" }
|
||||||
|
df = { optional=true, version="0.0.1", package="uu_df", path="src/uu/df" }
|
||||||
|
dircolors= { optional=true, version="0.0.1", package="uu_dircolors", path="src/uu/dircolors" }
|
||||||
|
dirname = { optional=true, version="0.0.1", package="uu_dirname", path="src/uu/dirname" }
|
||||||
|
du = { optional=true, version="0.0.1", package="uu_du", path="src/uu/du" }
|
||||||
|
echo = { optional=true, version="0.0.1", package="uu_echo", path="src/uu/echo" }
|
||||||
|
env = { optional=true, version="0.0.1", package="uu_env", path="src/uu/env" }
|
||||||
|
expand = { optional=true, version="0.0.1", package="uu_expand", path="src/uu/expand" }
|
||||||
|
expr = { optional=true, version="0.0.1", package="uu_expr", path="src/uu/expr" }
|
||||||
|
factor = { optional=true, version="0.0.1", package="uu_factor", path="src/uu/factor" }
|
||||||
|
false = { optional=true, version="0.0.1", package="uu_false", path="src/uu/false" }
|
||||||
|
fmt = { optional=true, version="0.0.1", package="uu_fmt", path="src/uu/fmt" }
|
||||||
|
fold = { optional=true, version="0.0.1", package="uu_fold", path="src/uu/fold" }
|
||||||
|
groups = { optional=true, version="0.0.1", package="uu_groups", path="src/uu/groups" }
|
||||||
|
hashsum = { optional=true, version="0.0.1", package="uu_hashsum", path="src/uu/hashsum" }
|
||||||
|
head = { optional=true, version="0.0.1", package="uu_head", path="src/uu/head" }
|
||||||
|
hostid = { optional=true, version="0.0.1", package="uu_hostid", path="src/uu/hostid" }
|
||||||
|
hostname = { optional=true, version="0.0.1", package="uu_hostname", path="src/uu/hostname" }
|
||||||
|
id = { optional=true, version="0.0.1", package="uu_id", path="src/uu/id" }
|
||||||
|
install = { optional=true, version="0.0.1", package="uu_install", path="src/uu/install" }
|
||||||
|
join = { optional=true, version="0.0.1", package="uu_join", path="src/uu/join" }
|
||||||
|
kill = { optional=true, version="0.0.1", package="uu_kill", path="src/uu/kill" }
|
||||||
|
link = { optional=true, version="0.0.1", package="uu_link", path="src/uu/link" }
|
||||||
|
ln = { optional=true, version="0.0.1", package="uu_ln", path="src/uu/ln" }
|
||||||
|
ls = { optional=true, version="0.0.1", package="uu_ls", path="src/uu/ls" }
|
||||||
|
logname = { optional=true, version="0.0.1", package="uu_logname", path="src/uu/logname" }
|
||||||
|
mkdir = { optional=true, version="0.0.1", package="uu_mkdir", path="src/uu/mkdir" }
|
||||||
|
mkfifo = { optional=true, version="0.0.1", package="uu_mkfifo", path="src/uu/mkfifo" }
|
||||||
|
mknod = { optional=true, version="0.0.1", package="uu_mknod", path="src/uu/mknod" }
|
||||||
|
mktemp = { optional=true, version="0.0.1", package="uu_mktemp", path="src/uu/mktemp" }
|
||||||
|
more = { optional=true, version="0.0.1", package="uu_more", path="src/uu/more" }
|
||||||
|
mv = { optional=true, version="0.0.1", package="uu_mv", path="src/uu/mv" }
|
||||||
|
nice = { optional=true, version="0.0.1", package="uu_nice", path="src/uu/nice" }
|
||||||
|
nl = { optional=true, version="0.0.1", package="uu_nl", path="src/uu/nl" }
|
||||||
|
nohup = { optional=true, version="0.0.1", package="uu_nohup", path="src/uu/nohup" }
|
||||||
|
nproc = { optional=true, version="0.0.1", package="uu_nproc", path="src/uu/nproc" }
|
||||||
|
numfmt = { optional=true, version="0.0.1", package="uu_numfmt", path="src/uu/numfmt" }
|
||||||
|
od = { optional=true, version="0.0.1", package="uu_od", path="src/uu/od" }
|
||||||
|
paste = { optional=true, version="0.0.1", package="uu_paste", path="src/uu/paste" }
|
||||||
|
pathchk = { optional=true, version="0.0.1", package="uu_pathchk", path="src/uu/pathchk" }
|
||||||
|
pinky = { optional=true, version="0.0.1", package="uu_pinky", path="src/uu/pinky" }
|
||||||
|
printenv = { optional=true, version="0.0.1", package="uu_printenv", path="src/uu/printenv" }
|
||||||
|
printf = { optional=true, version="0.0.1", package="uu_printf", path="src/uu/printf" }
|
||||||
|
ptx = { optional=true, version="0.0.1", package="uu_ptx", path="src/uu/ptx" }
|
||||||
|
pwd = { optional=true, version="0.0.1", package="uu_pwd", path="src/uu/pwd" }
|
||||||
|
readlink = { optional=true, version="0.0.1", package="uu_readlink", path="src/uu/readlink" }
|
||||||
|
realpath = { optional=true, version="0.0.1", package="uu_realpath", path="src/uu/realpath" }
|
||||||
|
relpath = { optional=true, version="0.0.1", package="uu_relpath", path="src/uu/relpath" }
|
||||||
|
rm = { optional=true, version="0.0.1", package="uu_rm", path="src/uu/rm" }
|
||||||
|
rmdir = { optional=true, version="0.0.1", package="uu_rmdir", path="src/uu/rmdir" }
|
||||||
|
seq = { optional=true, version="0.0.1", package="uu_seq", path="src/uu/seq" }
|
||||||
|
shred = { optional=true, version="0.0.1", package="uu_shred", path="src/uu/shred" }
|
||||||
|
shuf = { optional=true, version="0.0.1", package="uu_shuf", path="src/uu/shuf" }
|
||||||
|
sleep = { optional=true, version="0.0.1", package="uu_sleep", path="src/uu/sleep" }
|
||||||
|
sort = { optional=true, version="0.0.1", package="uu_sort", path="src/uu/sort" }
|
||||||
|
split = { optional=true, version="0.0.1", package="uu_split", path="src/uu/split" }
|
||||||
|
stat = { optional=true, version="0.0.1", package="uu_stat", path="src/uu/stat" }
|
||||||
|
stdbuf = { optional=true, version="0.0.1", package="uu_stdbuf", path="src/uu/stdbuf" }
|
||||||
|
sum = { optional=true, version="0.0.1", package="uu_sum", path="src/uu/sum" }
|
||||||
|
sync = { optional=true, version="0.0.1", package="uu_sync", path="src/uu/sync" }
|
||||||
|
tac = { optional=true, version="0.0.1", package="uu_tac", path="src/uu/tac" }
|
||||||
|
tail = { optional=true, version="0.0.1", package="uu_tail", path="src/uu/tail" }
|
||||||
|
tee = { optional=true, version="0.0.1", package="uu_tee", path="src/uu/tee" }
|
||||||
|
timeout = { optional=true, version="0.0.1", package="uu_timeout", path="src/uu/timeout" }
|
||||||
|
touch = { optional=true, version="0.0.1", package="uu_touch", path="src/uu/touch" }
|
||||||
|
tr = { optional=true, version="0.0.1", package="uu_tr", path="src/uu/tr" }
|
||||||
|
true = { optional=true, version="0.0.1", package="uu_true", path="src/uu/true" }
|
||||||
|
truncate = { optional=true, version="0.0.1", package="uu_truncate", path="src/uu/truncate" }
|
||||||
|
tsort = { optional=true, version="0.0.1", package="uu_tsort", path="src/uu/tsort" }
|
||||||
|
tty = { optional=true, version="0.0.1", package="uu_tty", path="src/uu/tty" }
|
||||||
|
uname = { optional=true, version="0.0.1", package="uu_uname", path="src/uu/uname" }
|
||||||
|
unexpand = { optional=true, version="0.0.1", package="uu_unexpand", path="src/uu/unexpand" }
|
||||||
|
uniq = { optional=true, version="0.0.1", package="uu_uniq", path="src/uu/uniq" }
|
||||||
|
unlink = { optional=true, version="0.0.1", package="uu_unlink", path="src/uu/unlink" }
|
||||||
|
uptime = { optional=true, version="0.0.1", package="uu_uptime", path="src/uu/uptime" }
|
||||||
|
users = { optional=true, version="0.0.1", package="uu_users", path="src/uu/users" }
|
||||||
|
wc = { optional=true, version="0.0.1", package="uu_wc", path="src/uu/wc" }
|
||||||
|
who = { optional=true, version="0.0.1", package="uu_who", path="src/uu/who" }
|
||||||
|
whoami = { optional=true, version="0.0.1", package="uu_whoami", path="src/uu/whoami" }
|
||||||
|
yes = { optional=true, version="0.0.1", package="uu_yes", path="src/uu/yes" }
|
||||||
|
#
|
||||||
|
# * pinned transitive dependencies
|
||||||
|
pin_backtrace = { version=">= 0.3.3, <= 0.3.30", package="backtrace" } ## via 'failure'; pin to <= v0.3.30 to avoid increasing MinSRV to v1.33.0
|
||||||
|
pin_half = { version="1.1.0, < 1.4.0", package="half" } ## half v1.4.0 has compiler errors for MinSRV v1.31.0
|
||||||
|
pin_same-file = { version="1.0.4, < 1.0.6", package="same-file" } ## same-file v1.0.6 has compiler errors for MinSRV v1.31.0
|
||||||
|
pin_winapi-util = { version="0.1.2, < 0.1.3", package="winapi-util" } ## winapi-util v0.1.3 has compiler errors for MinSRV v1.31.0
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
filetime = "0.2"
|
filetime = "0.2"
|
||||||
|
@ -324,17 +338,15 @@ regex = "1.0"
|
||||||
tempdir = "0.3"
|
tempdir = "0.3"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
unindent = "0.1"
|
unindent = "0.1"
|
||||||
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="master", features=["entries"] }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dev-dependencies]
|
[target.'cfg(unix)'.dev-dependencies]
|
||||||
rust-users = { version="0.10", package="users" }
|
rust-users = { version="0.10", package="users" }
|
||||||
unix_socket = "0.5.0"
|
unix_socket = "0.5.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "uutils"
|
name = "coreutils"
|
||||||
path = "src/bin/uutils.rs"
|
path = "src/bin/coreutils.rs"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "tests"
|
name = "tests"
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
uucore = { git = "https://github.com/uutils/uucore/", tag = "0.0.2" }
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
# spell-checker:ignore (cargo-make) duckscript macos
|
# spell-checker:ignore (cargo-make) duckscript
|
||||||
# spell-checker:ignore (rust) clippy
|
|
||||||
# spell-checker:ignore (uutils) uutil uutils
|
|
||||||
|
|
||||||
[config]
|
[config]
|
||||||
min_version = "0.26.2"
|
min_version = "0.26.2"
|
||||||
|
@ -81,10 +79,16 @@ if is_empty "${args_examples}"
|
||||||
end_if
|
end_if
|
||||||
set_env CARGO_MAKE_TASK_BUILD_EXAMPLES_ARGS "${args_examples}"
|
set_env CARGO_MAKE_TASK_BUILD_EXAMPLES_ARGS "${args_examples}"
|
||||||
# * rebuild for 'utils' target
|
# * rebuild for 'utils' target
|
||||||
args_utils = replace ${args} ";" " -p"
|
args_utils_list = split "${args}" ";"
|
||||||
if not is_empty "${args_utils}"
|
for arg in "${args_utils_list}"
|
||||||
args_utils = set "-p${args_utils}"
|
if not is_empty "${arg}"
|
||||||
end_if
|
if not starts_with "${arg}" "uu_"
|
||||||
|
arg = set "uu_${arg}"
|
||||||
|
end_if
|
||||||
|
args_utils = set "${args_utils} -p${arg}"
|
||||||
|
end_if
|
||||||
|
end
|
||||||
|
args_utils = trim "${args_utils}"
|
||||||
set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${args_utils}"
|
set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${args_utils}"
|
||||||
'''
|
'''
|
||||||
]
|
]
|
||||||
|
@ -118,7 +122,7 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[tasks.build-examples]
|
[tasks.build-examples]
|
||||||
description = "## Build (release-mode) project example(s); usage: `cargo make (build-examples | examples | example) [EXAMPLE]...`"
|
description = "## Build (release-mode) project example(s); usage: `cargo make (build-examples | examples) [EXAMPLE]...`"
|
||||||
category = "[project]"
|
category = "[project]"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core::pre-build",
|
"core::pre-build",
|
||||||
|
@ -135,11 +139,18 @@ dependencies = [
|
||||||
"core::post-build",
|
"core::post-build",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[tasks.build-release]
|
||||||
|
alias = "build"
|
||||||
|
|
||||||
[tasks.debug]
|
[tasks.debug]
|
||||||
alias = "build-debug"
|
alias = "build-debug"
|
||||||
|
|
||||||
[tasks.example]
|
[tasks.example]
|
||||||
alias = "build-examples"
|
description = "hidden singular-form alias for 'examples'"
|
||||||
|
category = "[project]"
|
||||||
|
dependencies = [
|
||||||
|
"examples",
|
||||||
|
]
|
||||||
|
|
||||||
[tasks.examples]
|
[tasks.examples]
|
||||||
alias = "build-examples"
|
alias = "build-examples"
|
||||||
|
@ -148,11 +159,10 @@ alias = "build-examples"
|
||||||
alias = "build-features"
|
alias = "build-features"
|
||||||
|
|
||||||
[tasks.format]
|
[tasks.format]
|
||||||
description = "## Format code files (with `cargo fmt`)"
|
description = "## Format code files (with `cargo fmt`; includes tests)"
|
||||||
category = "[project]"
|
category = "[project]"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"action-format",
|
"action-format",
|
||||||
"action-determine-tests",
|
|
||||||
"action-format-tests",
|
"action-format-tests",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -205,10 +215,7 @@ command = "cargo"
|
||||||
args = ["uninstall"]
|
args = ["uninstall"]
|
||||||
|
|
||||||
[tasks.util]
|
[tasks.util]
|
||||||
alias = "utils"
|
description = "## Build (individual; release-mode) utilities; usage: `cargo make (util | uutil) [UTIL_NAME...]`"
|
||||||
|
|
||||||
[tasks.utils]
|
|
||||||
description = "## Build (individual; release-mode) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME...]`"
|
|
||||||
category = "[project]"
|
category = "[project]"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core::pre-build",
|
"core::pre-build",
|
||||||
|
@ -217,11 +224,22 @@ dependencies = [
|
||||||
"core::post-build",
|
"core::post-build",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[tasks.utils]
|
||||||
|
description = "hidden plural-form alias for 'util'"
|
||||||
|
category = "[project]"
|
||||||
|
dependencies = [
|
||||||
|
"util",
|
||||||
|
]
|
||||||
|
|
||||||
[tasks.uutil]
|
[tasks.uutil]
|
||||||
alias = "utils"
|
alias = "utils"
|
||||||
|
|
||||||
[tasks.uutils]
|
[tasks.uutils]
|
||||||
alias = "utils"
|
description = "hidden plural-form alias for 'util'"
|
||||||
|
category = "[project]"
|
||||||
|
dependencies = [
|
||||||
|
"util",
|
||||||
|
]
|
||||||
|
|
||||||
### actions
|
### actions
|
||||||
|
|
||||||
|
@ -247,6 +265,9 @@ args = ["build", "--release", "--no-default-features", "--features", "${CARGO_MA
|
||||||
|
|
||||||
[tasks.action-build-utils]
|
[tasks.action-build-utils]
|
||||||
description = "Build individual utilities"
|
description = "Build individual utilities"
|
||||||
|
dependencies = [
|
||||||
|
"action-determine-utils",
|
||||||
|
]
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
# args = ["build", "@@remove-empty(CARGO_MAKE_TASK_BUILD_UTILS_ARGS)" ]
|
# args = ["build", "@@remove-empty(CARGO_MAKE_TASK_BUILD_UTILS_ARGS)" ]
|
||||||
args = ["build", "--release", "@@split(CARGO_MAKE_TASK_BUILD_UTILS_ARGS, )" ]
|
args = ["build", "--release", "@@split(CARGO_MAKE_TASK_BUILD_UTILS_ARGS, )" ]
|
||||||
|
@ -263,11 +284,21 @@ script = [
|
||||||
package_options = get_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS
|
package_options = get_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS
|
||||||
if is_empty "${package_options}"
|
if is_empty "${package_options}"
|
||||||
show_utils = get_env CARGO_MAKE_VAR_SHOW_UTILS
|
show_utils = get_env CARGO_MAKE_VAR_SHOW_UTILS
|
||||||
result = exec "${show_utils}"
|
features = get_env CARGO_MAKE_VAR_BUILD_TEST_FEATURES
|
||||||
|
if not is_empty "${features}"
|
||||||
|
result = exec "${show_utils}" --features "${features}"
|
||||||
|
else
|
||||||
|
result = exec "${show_utils}"
|
||||||
|
endif
|
||||||
set_env CARGO_MAKE_VAR_UTILS ${result.stdout}
|
set_env CARGO_MAKE_VAR_UTILS ${result.stdout}
|
||||||
utils = array %{result.stdout}
|
utils = array %{result.stdout}
|
||||||
for util in ${utils}
|
for util in ${utils}
|
||||||
package_options = set "${package_options} -p${util}"
|
if not is_empty "${util}"
|
||||||
|
if not starts_with "${util}" "uu_"
|
||||||
|
util = set "uu_${util}"
|
||||||
|
end_if
|
||||||
|
package_options = set "${package_options} -p${util}"
|
||||||
|
end_if
|
||||||
end
|
end
|
||||||
package_options = trim "${package_options}"
|
package_options = trim "${package_options}"
|
||||||
end_if
|
end_if
|
||||||
|
@ -281,10 +312,13 @@ script = [
|
||||||
'''
|
'''
|
||||||
test_files = glob_array tests/**/*.rs
|
test_files = glob_array tests/**/*.rs
|
||||||
for file in ${test_files}
|
for file in ${test_files}
|
||||||
if is_empty "${tests}"
|
file = replace "${file}" "\\" "/"
|
||||||
tests = set "${file}"
|
if not is_empty ${file}
|
||||||
else
|
if is_empty "${tests}"
|
||||||
tests = set "${tests} ${file}"
|
tests = set "${file}"
|
||||||
|
else
|
||||||
|
tests = set "${tests} ${file}"
|
||||||
|
end_if
|
||||||
end_if
|
end_if
|
||||||
end
|
end
|
||||||
set_env CARGO_MAKE_VAR_TESTS "${tests}"
|
set_env CARGO_MAKE_VAR_TESTS "${tests}"
|
||||||
|
@ -298,6 +332,9 @@ args = ["fmt"]
|
||||||
|
|
||||||
[tasks.action-format-tests]
|
[tasks.action-format-tests]
|
||||||
description = "`cargo fmt` tests"
|
description = "`cargo fmt` tests"
|
||||||
|
dependencies = [
|
||||||
|
"action-determine-tests",
|
||||||
|
]
|
||||||
command = "cargo"
|
command = "cargo"
|
||||||
args = ["fmt", "--", "@@split(CARGO_MAKE_VAR_TESTS, )"]
|
args = ["fmt", "--", "@@split(CARGO_MAKE_VAR_TESTS, )"]
|
||||||
|
|
||||||
|
@ -342,7 +379,7 @@ script = [
|
||||||
target = array_pop ${line_segments}
|
target = array_pop ${line_segments}
|
||||||
target = trim ${target}
|
target = trim ${target}
|
||||||
l = length ${target}
|
l = length ${target}
|
||||||
r = range 0 20
|
r = range 0 18
|
||||||
spacing = set ""
|
spacing = set ""
|
||||||
for i in ${r}
|
for i in ${r}
|
||||||
if greater_than ${i} ${l}
|
if greater_than ${i} ${l}
|
||||||
|
|
98
build.rs
98
build.rs
|
@ -1,3 +1,5 @@
|
||||||
|
// spell-checker:ignore (vars) krate
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -8,66 +10,89 @@ pub fn main() {
|
||||||
println!("cargo:rustc-cfg=build={:?}", profile);
|
println!("cargo:rustc-cfg=build={:?}", profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
let feature_prefix = "CARGO_FEATURE_";
|
let env_feature_prefix: &str = "CARGO_FEATURE_";
|
||||||
|
let feature_prefix: &str = "feat_";
|
||||||
|
let override_prefix: &str = "uu_";
|
||||||
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
|
||||||
let mut crates = Vec::new();
|
let mut crates = Vec::new();
|
||||||
for (key, val) in env::vars() {
|
for (key, val) in env::vars() {
|
||||||
if val == "1" && key.starts_with(feature_prefix) {
|
if val == "1" && key.starts_with(env_feature_prefix) {
|
||||||
let krate = key[feature_prefix.len()..].to_lowercase();
|
let krate = key[env_feature_prefix.len()..].to_lowercase();
|
||||||
match krate.as_ref() {
|
match krate.as_ref() {
|
||||||
"default" | "macos" | "unix" | "windows" => continue,
|
"default" | "macos" | "unix" | "windows" => continue, // common/standard feature names
|
||||||
"nightly" | "test_unimplemented" => continue,
|
"nightly" | "test_unimplemented" => continue, // crate-local custom features
|
||||||
s if s.starts_with("feat_") => continue,
|
"test" => continue, // over-ridden with 'uu_test' to avoid collision with rust core crate 'test'
|
||||||
_ => {}
|
s if s.starts_with(feature_prefix) => continue, // crate feature sets
|
||||||
|
_ => {} // util feature name
|
||||||
}
|
}
|
||||||
crates.push(krate.to_string());
|
crates.push(krate.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crates.sort();
|
crates.sort();
|
||||||
|
|
||||||
let mut cf = File::create(Path::new(&out_dir).join("uutils_crates.rs")).unwrap();
|
|
||||||
let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap();
|
let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap();
|
||||||
|
|
||||||
mf.write_all(
|
mf.write_all(
|
||||||
|
"type UtilityMap = HashMap<&'static str, fn(Vec<String>) -> i32>;\n\
|
||||||
|
\n\
|
||||||
|
fn util_map() -> UtilityMap {\n\
|
||||||
|
\tlet mut map: UtilityMap = HashMap::new();\n\
|
||||||
"
|
"
|
||||||
type UtilityMap = HashMap<&'static str, fn(Vec<String>) -> i32>;
|
.as_bytes(),
|
||||||
|
|
||||||
fn util_map() -> UtilityMap {
|
|
||||||
let mut map: UtilityMap = HashMap::new();\n"
|
|
||||||
.as_bytes(),
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
for krate in crates {
|
for krate in crates {
|
||||||
cf.write_all(format!("extern crate uu_{krate};\n", krate = krate).as_bytes())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
match krate.as_ref() {
|
match krate.as_ref() {
|
||||||
"hashsum" => {
|
k if k.starts_with(override_prefix) => mf
|
||||||
mf.write_all(
|
.write_all(
|
||||||
"map.insert(\"hashsum\", uu_hashsum::uumain);
|
format!(
|
||||||
map.insert(\"md5sum\", uu_hashsum::uumain);
|
"\tmap.insert(\"{k}\", {krate}::uumain);\n",
|
||||||
map.insert(\"sha1sum\", uu_hashsum::uumain);
|
k = krate[override_prefix.len()..].to_string(),
|
||||||
map.insert(\"sha224sum\", uu_hashsum::uumain);
|
krate = krate
|
||||||
map.insert(\"sha256sum\", uu_hashsum::uumain);
|
)
|
||||||
map.insert(\"sha384sum\", uu_hashsum::uumain);
|
.as_bytes(),
|
||||||
map.insert(\"sha512sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"sha3sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"sha3-224sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"sha3-256sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"sha3-384sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"sha3-512sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"shake128sum\", uu_hashsum::uumain);
|
|
||||||
map.insert(\"shake256sum\", uu_hashsum::uumain);\n"
|
|
||||||
.as_bytes(),
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap(),
|
||||||
}
|
"false" | "true" => mf
|
||||||
|
.write_all(
|
||||||
|
format!(
|
||||||
|
"\tmap.insert(\"{krate}\", r#{krate}::uumain);\n",
|
||||||
|
krate = krate
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
"hashsum" => mf
|
||||||
|
.write_all(
|
||||||
|
format!(
|
||||||
|
"\
|
||||||
|
\tmap.insert(\"{krate}\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"md5sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha1sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha224sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha256sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha384sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha512sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha3sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha3-224sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha3-256sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha3-384sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"sha3-512sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"shake128sum\", {krate}::uumain);\n\
|
||||||
|
\t\tmap.insert(\"shake256sum\", {krate}::uumain);\n\
|
||||||
|
",
|
||||||
|
krate = krate
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
_ => mf
|
_ => mf
|
||||||
.write_all(
|
.write_all(
|
||||||
format!(
|
format!(
|
||||||
"map.insert(\"{krate}\", uu_{krate}::uumain);\n",
|
"\tmap.insert(\"{krate}\", {krate}::uumain);\n",
|
||||||
krate = krate
|
krate = krate
|
||||||
)
|
)
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
|
@ -78,6 +103,5 @@ pub fn main() {
|
||||||
|
|
||||||
mf.write_all(b"map\n}\n").unwrap();
|
mf.write_all(b"map\n}\n").unwrap();
|
||||||
|
|
||||||
cf.flush().unwrap();
|
|
||||||
mf.flush().unwrap();
|
mf.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
1
examples/busybox-core.rs
Normal file
1
examples/busybox-core.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include!("../src/bin/coreutils.rs");
|
|
@ -1 +0,0 @@
|
||||||
include!("../src/bin/uutils.rs");
|
|
|
@ -1 +0,0 @@
|
||||||
include!("../src/bin/uutils.rs");
|
|
1
examples/uuc.rs
Normal file
1
examples/uuc.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include!("../src/bin/coreutils.rs");
|
|
@ -1,18 +1,9 @@
|
||||||
/*
|
// This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// (c) Michael Gehring <mg@ebfe.org>
|
||||||
* (c) Michael Gehring <mg@ebfe.org>
|
//
|
||||||
*
|
// For the full copyright and license information, please view the LICENSE
|
||||||
* For the full copyright and license information, please view the LICENSE
|
// file that was distributed with this source code.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// spell-checker:ignore (acronyms/names) Gehring
|
|
||||||
// spell-checker:ignore (rustlang/crates) clippy concat rustlang termwidth textwrap
|
|
||||||
// spell-checker:ignore (uutils) coreutils sigpipe uucore uumain uutils
|
|
||||||
// spell-checker:ignore (shell) busybox symlinks
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs"));
|
|
||||||
|
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate textwrap;
|
extern crate textwrap;
|
||||||
|
@ -53,7 +44,7 @@ fn usage(utils: &UtilityMap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
uucore::panic::install_sigpipe_hook();
|
uucore::panic::mute_sigpipe_panic();
|
||||||
|
|
||||||
let utils = util_map();
|
let utils = util_map();
|
||||||
let mut args: Vec<String> = uucore::args().collect();
|
let mut args: Vec<String> = uucore::args().collect();
|
|
@ -1,36 +0,0 @@
|
||||||
use std::env;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::Write;
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
static TEMPLATE: &str = "\
|
|
||||||
extern crate uu_@UTIL_CRATE@;
|
|
||||||
extern crate uucore;
|
|
||||||
|
|
||||||
use std::io::Write;
|
|
||||||
use uu_@UTIL_CRATE@::uumain;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
uucore::panic::install_sigpipe_hook();
|
|
||||||
|
|
||||||
let code = uumain(uucore::args().collect());
|
|
||||||
// Since stdout is line-buffered by default, we need to ensure any pending
|
|
||||||
// writes are flushed before exiting. Ideally, this should be enforced by
|
|
||||||
// each utility.
|
|
||||||
//
|
|
||||||
// See: https://github.com/rust-lang/rust/issues/23818
|
|
||||||
//
|
|
||||||
std::io::stdout().flush().expect(\"could not flush stdout\");
|
|
||||||
std::process::exit(code);
|
|
||||||
}
|
|
||||||
";
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
|
||||||
let pkgname = env::var("CARGO_PKG_NAME").unwrap();
|
|
||||||
|
|
||||||
let main = TEMPLATE.replace("@UTIL_CRATE@", &pkgname);
|
|
||||||
let mut file = File::create(&Path::new(&out_dir).join("main.rs")).unwrap();
|
|
||||||
|
|
||||||
write!(file, "{}", main).unwrap();
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
include!(concat!(env!("OUT_DIR"), "/main.rs"));
|
|
|
@ -1,18 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "arch"
|
name = "uu_arch"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "arch ~ (uutils) display machine architecture"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/arch"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_arch"
|
|
||||||
path = "src/arch.rs"
|
path = "src/arch.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
platform-info = "0.0.1"
|
platform-info = "0.0.1"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "arch"
|
name = "arch"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![crate_name = "uu_arch"]
|
|
||||||
|
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
// (c) Smigle00 <smigle00@gmail.com>
|
// (c) Smigle00 <smigle00@gmail.com>
|
||||||
|
@ -7,7 +5,6 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
|
||||||
|
|
||||||
extern crate platform_info;
|
extern crate platform_info;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -20,7 +17,7 @@ static SUMMARY: &str = "Determine architecture name for current machine.";
|
||||||
static LONG_HELP: &str = "";
|
static LONG_HELP: &str = "";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
||||||
let uts = return_if_err!(1, PlatformInfo::new());
|
let uts = return_if_err!(1, PlatformInfo::new());
|
||||||
println!("{}", uts.machine().trim());
|
println!("{}", uts.machine().trim());
|
||||||
0
|
0
|
||||||
|
|
1
src/uu/arch/src/main.rs
Normal file
1
src/uu/arch/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_arch); // spell-checker:ignore procs uucore
|
|
@ -1,19 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "base32"
|
name = "uu_base32"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "base32 ~ (uutils) decode/encode input (base32-encoding)"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/base32"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_base32"
|
|
||||||
path = "src/base32.rs"
|
path = "src/base32.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uucore = { version = "0.0.2", features = ["encoding"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features = ["encoding"] }
|
||||||
## optional
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
clippy = { version = "0.0.212", optional = true }
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "base32"
|
name = "base32"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -4,15 +4,11 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE file
|
// For the full copyright and license information, please view the LICENSE file
|
||||||
// that was distributed with this source code.
|
// that was distributed with this source code.
|
||||||
//
|
|
||||||
|
|
||||||
#![crate_name = "uu_base32"]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
use uucore::encoding::Format;
|
use uucore::encoding::Format;
|
||||||
|
|
||||||
#[path = "../../base64/src/base_common.rs"]
|
|
||||||
mod base_common;
|
mod base_common;
|
||||||
|
|
||||||
static SYNTAX: &str = "[OPTION]... [FILE]";
|
static SYNTAX: &str = "[OPTION]... [FILE]";
|
||||||
|
|
92
src/uu/base32/src/base_common.rs
Normal file
92
src/uu/base32/src/base_common.rs
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Jordy Dickinson <jordy.dickinson@gmail.com>
|
||||||
|
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
||||||
|
// (c) Alex Lyon <arcterus@mail.com>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE file
|
||||||
|
// that was distributed with this source code.
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{stdin, BufReader, Read};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use uucore::encoding::{wrap_print, Data, Format};
|
||||||
|
|
||||||
|
pub fn execute(
|
||||||
|
args: Vec<String>,
|
||||||
|
syntax: &str,
|
||||||
|
summary: &str,
|
||||||
|
long_help: &str,
|
||||||
|
format: Format,
|
||||||
|
) -> i32 {
|
||||||
|
let matches = app!(syntax, summary, long_help)
|
||||||
|
.optflag("d", "decode", "decode data")
|
||||||
|
.optflag(
|
||||||
|
"i",
|
||||||
|
"ignore-garbage",
|
||||||
|
"when decoding, ignore non-alphabetic characters",
|
||||||
|
)
|
||||||
|
.optopt(
|
||||||
|
"w",
|
||||||
|
"wrap",
|
||||||
|
"wrap encoded lines after COLS character (default 76, 0 to disable wrapping)",
|
||||||
|
"COLS",
|
||||||
|
)
|
||||||
|
.parse(args);
|
||||||
|
|
||||||
|
let line_wrap = matches.opt_str("wrap").map(|s| match s.parse() {
|
||||||
|
Ok(n) => n,
|
||||||
|
Err(e) => {
|
||||||
|
crash!(1, "invalid wrap size: ‘{}’: {}", s, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let ignore_garbage = matches.opt_present("ignore-garbage");
|
||||||
|
let decode = matches.opt_present("decode");
|
||||||
|
|
||||||
|
if matches.free.len() > 1 {
|
||||||
|
show_usage_error!("extra operand ‘{}’", matches.free[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches.free.is_empty() || &matches.free[0][..] == "-" {
|
||||||
|
let stdin_raw = stdin();
|
||||||
|
handle_input(
|
||||||
|
&mut stdin_raw.lock(),
|
||||||
|
format,
|
||||||
|
line_wrap,
|
||||||
|
ignore_garbage,
|
||||||
|
decode,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let path = Path::new(matches.free[0].as_str());
|
||||||
|
let file_buf = safe_unwrap!(File::open(&path));
|
||||||
|
let mut input = BufReader::new(file_buf);
|
||||||
|
handle_input(&mut input, format, line_wrap, ignore_garbage, decode);
|
||||||
|
};
|
||||||
|
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_input<R: Read>(
|
||||||
|
input: &mut R,
|
||||||
|
format: Format,
|
||||||
|
line_wrap: Option<usize>,
|
||||||
|
ignore_garbage: bool,
|
||||||
|
decode: bool,
|
||||||
|
) {
|
||||||
|
let mut data = Data::new(input, format).ignore_garbage(ignore_garbage);
|
||||||
|
if let Some(wrap) = line_wrap {
|
||||||
|
data = data.line_wrap(wrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !decode {
|
||||||
|
let encoded = data.encode();
|
||||||
|
wrap_print(&data, encoded);
|
||||||
|
} else {
|
||||||
|
match data.decode() {
|
||||||
|
Ok(s) => print!("{}", String::from_utf8(s).unwrap()),
|
||||||
|
Err(_) => crash!(1, "invalid input"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
src/uu/base32/src/main.rs
Normal file
1
src/uu/base32/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_base32); // spell-checker:ignore procs uucore
|
|
@ -1,17 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "base64"
|
name = "uu_base64"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "base64 ~ (uutils) decode/encode input (base64-encoding)"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/base64"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_base64"
|
|
||||||
path = "src/base64.rs"
|
path = "src/base64.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uucore = { version = "0.0.2", features = ["encoding"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features = ["encoding"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![crate_name = "uu_base64"]
|
|
||||||
|
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
// (c) Jordy Dickinson <jordy.dickinson@gmail.com>
|
// (c) Jordy Dickinson <jordy.dickinson@gmail.com>
|
||||||
|
@ -7,7 +5,6 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE file
|
// For the full copyright and license information, please view the LICENSE file
|
||||||
// that was distributed with this source code.
|
// that was distributed with this source code.
|
||||||
//
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
|
|
@ -6,15 +6,13 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE file
|
// For the full copyright and license information, please view the LICENSE file
|
||||||
// that was distributed with this source code.
|
// that was distributed with this source code.
|
||||||
//
|
|
||||||
|
|
||||||
use uucore;
|
|
||||||
use uucore::encoding::{wrap_print, Data, Format};
|
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{stdin, BufReader, Read};
|
use std::io::{stdin, BufReader, Read};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use uucore::encoding::{wrap_print, Data, Format};
|
||||||
|
|
||||||
pub fn execute(
|
pub fn execute(
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
syntax: &str,
|
syntax: &str,
|
||||||
|
@ -22,7 +20,7 @@ pub fn execute(
|
||||||
long_help: &str,
|
long_help: &str,
|
||||||
format: Format,
|
format: Format,
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
let matches = new_coreopts!(syntax, summary, long_help)
|
let matches = app!(syntax, summary, long_help)
|
||||||
.optflag("d", "decode", "decode data")
|
.optflag("d", "decode", "decode data")
|
||||||
.optflag(
|
.optflag(
|
||||||
"i",
|
"i",
|
||||||
|
@ -47,7 +45,7 @@ pub fn execute(
|
||||||
let decode = matches.opt_present("decode");
|
let decode = matches.opt_present("decode");
|
||||||
|
|
||||||
if matches.free.len() > 1 {
|
if matches.free.len() > 1 {
|
||||||
disp_err!("extra operand ‘{}’", matches.free[0]);
|
show_usage_error!("extra operand ‘{}’", matches.free[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/uu/base64/src/main.rs
Normal file
1
src/uu/base64/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_base64); // spell-checker:ignore procs uucore
|
|
@ -1,17 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "basename"
|
name = "uu_basename"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "basename ~ (uutils) display PATHNAME with leading directory components removed"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/basename"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_basename"
|
|
||||||
path = "src/basename.rs"
|
path = "src/basename.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "basename"
|
name = "basename"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_basename"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Jimmy Lu <jimmy.lu.2011@gmail.com>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) fullname
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Jimmy Lu <jimmy.lu.2011@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -24,7 +22,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
//
|
//
|
||||||
// Argument parsing
|
// Argument parsing
|
||||||
//
|
//
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optflag(
|
.optflag(
|
||||||
"a",
|
"a",
|
||||||
"multiple",
|
"multiple",
|
||||||
|
|
1
src/uu/basename/src/main.rs
Normal file
1
src/uu/basename/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_basename); // spell-checker:ignore procs uucore
|
|
@ -1,21 +1,27 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cat"
|
name = "uu_cat"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "cat ~ (uutils) concatenate and display input"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/cat"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_cat"
|
|
||||||
path = "src/cat.rs"
|
path = "src/cat.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quick-error = "1.2.3"
|
quick-error = "1.2.3"
|
||||||
uucore = { version = "0.0.2", features = ["fs"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
unix_socket = "0.5.0"
|
unix_socket = "0.5.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cat"
|
name = "cat"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![crate_name = "uu_cat"]
|
|
||||||
|
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
// (c) Jordi Boggiano <j.boggiano@seld.be>
|
// (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
@ -8,7 +6,8 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
|
||||||
|
// spell-checker:ignore (ToDO) nonprint nonblank nonprinting
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate quick_error;
|
extern crate quick_error;
|
||||||
|
@ -126,7 +125,7 @@ enum InputType {
|
||||||
type CatResult<T> = Result<T, CatError>;
|
type CatResult<T> = Result<T, CatError>;
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optflag("A", "show-all", "equivalent to -vET")
|
.optflag("A", "show-all", "equivalent to -vET")
|
||||||
.optflag(
|
.optflag(
|
||||||
"b",
|
"b",
|
||||||
|
@ -268,7 +267,7 @@ fn open(path: &str) -> CatResult<InputHandle> {
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `files` - There is no short circuit when encountiner an error
|
/// * `files` - There is no short circuit when encountering an error
|
||||||
/// reading a file in this vector
|
/// reading a file in this vector
|
||||||
fn write_fast(files: Vec<String>) -> CatResult<()> {
|
fn write_fast(files: Vec<String>) -> CatResult<()> {
|
||||||
let mut writer = stdout();
|
let mut writer = stdout();
|
||||||
|
@ -313,7 +312,7 @@ struct OutputState {
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `files` - There is no short circuit when encountiner an error
|
/// * `files` - There is no short circuit when encountering an error
|
||||||
/// reading a file in this vector
|
/// reading a file in this vector
|
||||||
fn write_lines(files: Vec<String>, options: &OutputOptions) -> CatResult<()> {
|
fn write_lines(files: Vec<String>, options: &OutputOptions) -> CatResult<()> {
|
||||||
let mut error_count = 0;
|
let mut error_count = 0;
|
||||||
|
@ -335,7 +334,7 @@ fn write_lines(files: Vec<String>, options: &OutputOptions) -> CatResult<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outputs file contents to stdout in a linewise fashion,
|
/// Outputs file contents to stdout in a line-by-line fashion,
|
||||||
/// propagating any errors that might occur.
|
/// propagating any errors that might occur.
|
||||||
fn write_file_lines(file: &str, options: &OutputOptions, state: &mut OutputState) -> CatResult<()> {
|
fn write_file_lines(file: &str, options: &OutputOptions, state: &mut OutputState) -> CatResult<()> {
|
||||||
let mut handle = open(file)?;
|
let mut handle = open(file)?;
|
||||||
|
|
1
src/uu/cat/src/main.rs
Normal file
1
src/uu/cat/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_cat); // spell-checker:ignore procs uucore
|
|
@ -1,18 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chgrp"
|
name = "uu_chgrp"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "chgrp ~ (uutils) change the group ownership of FILE"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/chgrp"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_chgrp"
|
|
||||||
path = "src/chgrp.rs"
|
path = "src/chgrp.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uucore = { version = "0.0.2", features = ["entries", "fs"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "fs"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
walkdir = "2.2.8"
|
walkdir = "2.2.8"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "chgrp"
|
name = "chgrp"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#![crate_name = "uu_chgrp"]
|
|
||||||
|
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
|
||||||
|
// spell-checker:ignore (ToDO) COMFOLLOW Chgrper RFILE RFILE's derefer dgid nonblank nonprint nonprinting
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -38,7 +37,7 @@ const FTS_PHYSICAL: u8 = 1 << 1;
|
||||||
const FTS_LOGICAL: u8 = 1 << 2;
|
const FTS_LOGICAL: u8 = 1 << 2;
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let mut opts = new_coreopts!(SYNTAX, SUMMARY, "");
|
let mut opts = app!(SYNTAX, SUMMARY, "");
|
||||||
opts.optflag("c",
|
opts.optflag("c",
|
||||||
"changes",
|
"changes",
|
||||||
"like verbose but report only when a change is made")
|
"like verbose but report only when a change is made")
|
||||||
|
@ -118,10 +117,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.free.is_empty() {
|
if matches.free.is_empty() {
|
||||||
disp_err!("missing operand");
|
show_usage_error!("missing operand");
|
||||||
return 1;
|
return 1;
|
||||||
} else if matches.free.len() < 2 && !matches.opt_present("reference") {
|
} else if matches.free.len() < 2 && !matches.opt_present("reference") {
|
||||||
disp_err!("missing operand after ‘{}’", matches.free[0]);
|
show_usage_error!("missing operand after ‘{}’", matches.free[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/uu/chgrp/src/main.rs
Normal file
1
src/uu/chgrp/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_chgrp); // spell-checker:ignore procs uucore
|
|
@ -1,19 +1,25 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chmod"
|
name = "uu_chmod"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "chmod ~ (uutils) change mode of FILE"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/chmod"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_chmod"
|
|
||||||
path = "src/chmod.rs"
|
path = "src/chmod.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
uucore = { version = "0.0.2", features = ["mode"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs", "mode"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
walker = "1.0.0"
|
walker = "1.0.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "chmod"
|
name = "chmod"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_chmod"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Alex Lyon <arcterus@mail.com>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) Chmoder cmode fmode fperm fref ugoa RFILE RFILE's
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Alex Lyon <arcterus@mail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
@ -38,7 +36,7 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
|
||||||
{0} [OPTION]... --reference=RFILE FILE...",
|
{0} [OPTION]... --reference=RFILE FILE...",
|
||||||
NAME
|
NAME
|
||||||
);
|
);
|
||||||
let mut opts = new_coreopts!(&syntax, SUMMARY, LONG_HELP);
|
let mut opts = app!(&syntax, SUMMARY, LONG_HELP);
|
||||||
opts.optflag(
|
opts.optflag(
|
||||||
"c",
|
"c",
|
||||||
"changes",
|
"changes",
|
||||||
|
@ -65,7 +63,7 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
|
||||||
)
|
)
|
||||||
.optflag("R", "recursive", "change files and directories recursively");
|
.optflag("R", "recursive", "change files and directories recursively");
|
||||||
|
|
||||||
// sanitize input for - at beginning (e.g. chmod -x testfile). Remove
|
// sanitize input for - at beginning (e.g. chmod -x test_file). Remove
|
||||||
// the option and save it for later, after parsing is finished.
|
// the option and save it for later, after parsing is finished.
|
||||||
let negative_option = sanitize_input(&mut args);
|
let negative_option = sanitize_input(&mut args);
|
||||||
|
|
||||||
|
|
1
src/uu/chmod/src/main.rs
Normal file
1
src/uu/chmod/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_chmod); // spell-checker:ignore procs uucore
|
|
@ -1,23 +1,25 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chown"
|
name = "uu_chown"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "chown ~ (uutils) change the ownership of FILE"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/chown"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_chown"
|
|
||||||
path = "src/chown.rs"
|
path = "src/chown.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glob = "0.3.0"
|
glob = "0.3.0"
|
||||||
uucore = { version = "0.0.2", features = ["entries", "fs"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "fs"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
walkdir = "2.2"
|
walkdir = "2.2"
|
||||||
|
|
||||||
[dependencies.clippy]
|
|
||||||
version = "0.0.212"
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "chown"
|
name = "chown"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_chown"]
|
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
|
||||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
// spell-checker:ignore (ToDO) COMFOLLOW Chowner Passwd RFILE RFILE's derefer dgid duid
|
||||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -39,7 +37,7 @@ const FTS_PHYSICAL: u8 = 1 << 1;
|
||||||
const FTS_LOGICAL: u8 = 1 << 2;
|
const FTS_LOGICAL: u8 = 1 << 2;
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let mut opts = new_coreopts!(SYNTAX, SUMMARY, "");
|
let mut opts = app!(SYNTAX, SUMMARY, "");
|
||||||
opts.optflag("c",
|
opts.optflag("c",
|
||||||
"changes",
|
"changes",
|
||||||
"like verbose but report only when a change is made")
|
"like verbose but report only when a change is made")
|
||||||
|
@ -137,10 +135,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.free.is_empty() {
|
if matches.free.is_empty() {
|
||||||
disp_err!("missing operand");
|
show_usage_error!("missing operand");
|
||||||
return 1;
|
return 1;
|
||||||
} else if matches.free.len() < 2 && !matches.opt_present("reference") {
|
} else if matches.free.len() < 2 && !matches.opt_present("reference") {
|
||||||
disp_err!("missing operand after ‘{}’", matches.free[0]);
|
show_usage_error!("missing operand after ‘{}’", matches.free[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/uu/chown/src/main.rs
Normal file
1
src/uu/chown/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_chown); // spell-checker:ignore procs uucore
|
|
@ -1,18 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chroot"
|
name = "uu_chroot"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "chroot ~ (uutils) run COMMAND under a new root directory"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/chroot"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_chroot"
|
|
||||||
path = "src/chroot.rs"
|
path = "src/chroot.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
getopts = "0.2.18"
|
getopts = "0.2.18"
|
||||||
uucore = { version = "0.0.2", features = ["entries"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "chroot"
|
name = "chroot"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
#![crate_name = "uu_chroot"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Vsevolod Velichko <torkvemada@sorokdva.net>
|
||||||
|
// (c) Jian Zeng <anonymousknight96 AT gmail.com>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) NEWROOT Userspec pstatus
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Vsevolod Velichko <torkvemada@sorokdva.net>
|
|
||||||
* (c) Jian Zeng <anonymousknight96 AT gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@ static LONG_HELP: &str = "
|
||||||
";
|
";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optopt(
|
.optopt(
|
||||||
"u",
|
"u",
|
||||||
"user",
|
"user",
|
||||||
|
|
1
src/uu/chroot/src/main.rs
Normal file
1
src/uu/chroot/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_chroot); // spell-checker:ignore procs uucore
|
|
@ -1,17 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cksum"
|
name = "uu_cksum"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
description = "cksum ~ (uutils) display CRC and size of input"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/cksum"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_cksum"
|
|
||||||
path = "src/cksum.rs"
|
path = "src/cksum.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cksum"
|
name = "cksum"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
/*
|
// This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// (c) Alex Lyon <arcterus@mail.com>
|
||||||
* (c) Alex Lyon <arcterus@mail.com>
|
// (c) Michael Gehring <mg@ebfe.org>
|
||||||
* (c) Michael Gehring <mg@ebfe.org>
|
//
|
||||||
*
|
// For the full copyright and license information, please view the LICENSE
|
||||||
* For the full copyright and license information, please view the LICENSE
|
// file that was distributed with this source code.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -15,12 +13,7 @@ use std::path::Path;
|
||||||
|
|
||||||
const CRC_TABLE_LEN: usize = 256;
|
const CRC_TABLE_LEN: usize = 256;
|
||||||
|
|
||||||
#[path = "../../common/mkmain.rs"]
|
|
||||||
mod mkmain;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mkmain::main();
|
|
||||||
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
|
||||||
let mut table = Vec::with_capacity(CRC_TABLE_LEN);
|
let mut table = Vec::with_capacity(CRC_TABLE_LEN);
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_cksum"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Michael Gehring <mg@ebfe.org>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) fname
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Michael Gehring <mg@ebfe.org>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -74,7 +72,7 @@ fn cksum(fname: &str) -> io::Result<(u32, usize)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
||||||
|
|
||||||
let files = matches.free;
|
let files = matches.free;
|
||||||
|
|
||||||
|
|
1
src/uu/cksum/src/main.rs
Normal file
1
src/uu/cksum/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_cksum); // spell-checker:ignore procs uucore
|
|
@ -1,19 +1,25 @@
|
||||||
[package]
|
[package]
|
||||||
name = "comm"
|
name = "uu_comm"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "comm ~ (uutils) compare sorted inputs"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/comm"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_comm"
|
|
||||||
path = "src/comm.rs"
|
path = "src/comm.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
getopts = "0.2.18"
|
getopts = "0.2.18"
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "comm"
|
name = "comm"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_comm"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Michael Gehring <mg@ebfe.org>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) delim mkdelim
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Michael Gehring <mg@ebfe.org>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
||||||
|
@ -124,7 +122,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optflag("1", "", "suppress column 1 (lines uniq to FILE1)")
|
.optflag("1", "", "suppress column 1 (lines uniq to FILE1)")
|
||||||
.optflag("2", "", "suppress column 2 (lines uniq to FILE2)")
|
.optflag("2", "", "suppress column 2 (lines uniq to FILE2)")
|
||||||
.optflag(
|
.optflag(
|
||||||
|
|
1
src/uu/comm/src/main.rs
Normal file
1
src/uu/comm/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_comm); // spell-checker:ignore procs uucore
|
|
@ -1,15 +1,21 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cp"
|
name = "uu_cp"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = [
|
authors = [
|
||||||
"Jordy Dickinson <jordy.dickinson@gmail.com>",
|
"Jordy Dickinson <jordy.dickinson@gmail.com>",
|
||||||
"Joshua S. Miller <jsmiller@uchicago.edu>",
|
"Joshua S. Miller <jsmiller@uchicago.edu>",
|
||||||
|
"uutils developers",
|
||||||
]
|
]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "cp ~ (uutils) copy SOURCE to DESTINATION"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/cp"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_cp"
|
|
||||||
path = "src/cp.rs"
|
path = "src/cp.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -17,19 +23,19 @@ clap = "2.32"
|
||||||
filetime = "0.2"
|
filetime = "0.2"
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
quick-error = "1.2.3"
|
quick-error = "1.2.3"
|
||||||
uucore = { version = "0.0.2", features = ["fs"] }
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
walkdir = "2.2.8"
|
walkdir = "2.2.8"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
ioctl-sys = "0.5.2"
|
ioctl-sys = "0.5.2"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
kernel32-sys = "0.2.2"
|
winapi = { version="0.3", features=["fileapi"] }
|
||||||
winapi = "0.3"
|
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
xattr="0.2.1"
|
xattr="0.2.1"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cp"
|
name = "cp"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
<!-- spell-checker:ignore (markdown) markdownlint -->
|
||||||
|
|
||||||
## Feature list
|
## Feature list
|
||||||
|
|
||||||
|
<!-- spell-checker:ignore (options) linkgs reflink -->
|
||||||
|
|
||||||
### To Do
|
### To Do
|
||||||
|
|
||||||
- [ ] archive
|
- [ ] archive
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
#![crate_name = "uu_cp"]
|
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
|
|
||||||
/*
|
// This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// (c) Jordy Dickinson <jordy.dickinson@gmail.com>
|
||||||
* (c) Jordy Dickinson <jordy.dickinson@gmail.com>
|
// (c) Joshua S. Miller <jsmiller@uchicago.edu>
|
||||||
* (c) Joshua S. Miller <jsmiller@uchicago.edu>
|
//
|
||||||
*
|
// For the full copyright and license information, please view the LICENSE file
|
||||||
* For the full copyright and license information, please view the LICENSE file
|
// that was distributed with this source code.
|
||||||
* that was distributed with this source code.
|
|
||||||
*/
|
// spell-checker:ignore (ToDO) ficlone linkgs lstat nlink nlinks pathbuf reflink strs xattrs
|
||||||
|
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate filetime;
|
extern crate filetime;
|
||||||
|
@ -25,14 +24,12 @@ extern crate walkdir;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
extern crate xattr;
|
extern crate xattr;
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
extern crate kernel32;
|
|
||||||
#[cfg(windows)]
|
|
||||||
use kernel32::CreateFileW;
|
|
||||||
#[cfg(windows)]
|
|
||||||
use kernel32::GetFileInformationByHandle;
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use winapi::um::fileapi::CreateFileW;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use winapi::um::fileapi::GetFileInformationByHandle;
|
||||||
|
|
||||||
use clap::{App, Arg, ArgMatches};
|
use clap::{App, Arg, ArgMatches};
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
|
@ -695,7 +692,7 @@ fn parse_path_args(path_args: &[String], options: &Options) -> CopyResult<(Vec<S
|
||||||
|
|
||||||
let (sources, target) = match options.target_dir {
|
let (sources, target) = match options.target_dir {
|
||||||
Some(ref target) => {
|
Some(ref target) => {
|
||||||
// All path arges are sources, and the target dir was
|
// All path args are sources, and the target dir was
|
||||||
// specified separately
|
// specified separately
|
||||||
(paths, PathBuf::from(target))
|
(paths, PathBuf::from(target))
|
||||||
}
|
}
|
||||||
|
@ -872,7 +869,7 @@ fn copy_source(
|
||||||
/// Read the contents of the directory `root` and recursively copy the
|
/// Read the contents of the directory `root` and recursively copy the
|
||||||
/// contents to `target`.
|
/// contents to `target`.
|
||||||
///
|
///
|
||||||
/// Any errors encounted copying files in the tree will be logged but
|
/// Any errors encountered copying files in the tree will be logged but
|
||||||
/// will not cause a short-circuit.
|
/// will not cause a short-circuit.
|
||||||
fn copy_directory(root: &Path, target: &Target, options: &Options) -> CopyResult<()> {
|
fn copy_directory(root: &Path, target: &Target, options: &Options) -> CopyResult<()> {
|
||||||
if !options.recursive {
|
if !options.recursive {
|
||||||
|
@ -1046,7 +1043,7 @@ fn handle_existing_dest(source: &Path, dest: &Path, options: &Options) -> CopyRe
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy the a file from `source` to `dest`. No path manipulation is
|
/// Copy the a file from `source` to `dest`. No path manipulation is
|
||||||
/// done on either `source` or `dest`, the are used as provieded.
|
/// done on either `source` or `dest`, the are used as provided.
|
||||||
///
|
///
|
||||||
/// Behavior when copying to existing files is contingent on the
|
/// Behavior when copying to existing files is contingent on the
|
||||||
/// `options.overwrite` mode. If a file is skipped, the return type
|
/// `options.overwrite` mode. If a file is skipped, the return type
|
||||||
|
|
1
src/uu/cp/src/main.rs
Normal file
1
src/uu/cp/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_cp); // spell-checker:ignore procs uucore
|
1
src/uu/cut/.gitignore
vendored
1
src/uu/cut/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
target
|
|
|
@ -1,17 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cut"
|
name = "uu_cut"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "cut ~ (uutils) display byte/field columns of input lines"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/cut"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_cut"
|
|
||||||
path = "src/cut.rs"
|
path = "src/cut.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cut"
|
name = "cut"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
/*
|
// This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// (c) Rolf Morel <rolfmorel@gmail.com>
|
||||||
* (c) Rolf Morel <rolfmorel@gmail.com>
|
// (c) kwantam <kwantam@gmail.com>
|
||||||
* (c) kwantam <kwantam@gmail.com>
|
// * substantial rewrite to use the `std::io::BufReader` trait
|
||||||
* substantially rewritten to use the stdlib BufReader trait
|
//
|
||||||
* rather than re-implementing it here.
|
// For the full copyright and license information, please view the LICENSE
|
||||||
*
|
// file that was distributed with this source code.
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
// spell-checker:ignore (ToDO) SRes Newl
|
||||||
*/
|
|
||||||
|
|
||||||
use std::io::Result as IoResult;
|
use std::io::Result as IoResult;
|
||||||
use std::io::{BufRead, BufReader, Read, Write};
|
use std::io::{BufRead, BufReader, Read, Write};
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_cut"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Rolf Morel <rolfmorel@gmail.com>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) delim sourcefiles
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Rolf Morel <rolfmorel@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -16,8 +14,8 @@ use std::fs::File;
|
||||||
use std::io::{stdin, stdout, BufRead, BufReader, Read, Stdout, Write};
|
use std::io::{stdin, stdout, BufRead, BufReader, Read, Stdout, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use ranges::Range;
|
use self::ranges::Range;
|
||||||
use searcher::Searcher;
|
use self::searcher::Searcher;
|
||||||
|
|
||||||
mod buffer;
|
mod buffer;
|
||||||
mod ranges;
|
mod ranges;
|
||||||
|
@ -114,7 +112,7 @@ struct Options {
|
||||||
|
|
||||||
struct FieldOptions {
|
struct FieldOptions {
|
||||||
delimiter: String, // one char long, String because of UTF8 representation
|
delimiter: String, // one char long, String because of UTF8 representation
|
||||||
out_delimeter: Option<String>,
|
out_delimiter: Option<String>,
|
||||||
only_delimited: bool,
|
only_delimited: bool,
|
||||||
zero_terminated: bool,
|
zero_terminated: bool,
|
||||||
}
|
}
|
||||||
|
@ -134,8 +132,8 @@ fn list_to_ranges(list: &str, complement: bool) -> Result<Vec<Range>, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cut_bytes<R: Read>(reader: R, ranges: &[Range], opts: &Options) -> i32 {
|
fn cut_bytes<R: Read>(reader: R, ranges: &[Range], opts: &Options) -> i32 {
|
||||||
use buffer::Bytes::Select;
|
use self::buffer::Bytes::Select;
|
||||||
use buffer::Bytes::Selected::*;
|
use self::buffer::Bytes::Selected::*;
|
||||||
|
|
||||||
let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' };
|
let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' };
|
||||||
let mut buf_read = buffer::ByteReader::new(reader, newline_char);
|
let mut buf_read = buffer::ByteReader::new(reader, newline_char);
|
||||||
|
@ -292,7 +290,7 @@ fn cut_fields_delimiter<R: Read>(
|
||||||
#[allow(clippy::cognitive_complexity)]
|
#[allow(clippy::cognitive_complexity)]
|
||||||
fn cut_fields<R: Read>(reader: R, ranges: &[Range], opts: &FieldOptions) -> i32 {
|
fn cut_fields<R: Read>(reader: R, ranges: &[Range], opts: &FieldOptions) -> i32 {
|
||||||
let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' };
|
let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' };
|
||||||
if let Some(ref o_delim) = opts.out_delimeter {
|
if let Some(ref o_delim) = opts.out_delimiter {
|
||||||
return cut_fields_delimiter(
|
return cut_fields_delimiter(
|
||||||
reader,
|
reader,
|
||||||
ranges,
|
ranges,
|
||||||
|
@ -426,7 +424,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optopt("b", "bytes", "filter byte columns from the input source", "sequence")
|
.optopt("b", "bytes", "filter byte columns from the input source", "sequence")
|
||||||
.optopt("c", "characters", "alias for character mode", "sequence")
|
.optopt("c", "characters", "alias for character mode", "sequence")
|
||||||
.optopt("d", "delimiter", "specify the delimiter character that separates fields in the input source. Defaults to Tab.", "delimiter")
|
.optopt("d", "delimiter", "specify the delimiter character that separates fields in the input source. Defaults to Tab.", "delimiter")
|
||||||
|
@ -502,7 +500,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
ranges,
|
ranges,
|
||||||
FieldOptions {
|
FieldOptions {
|
||||||
delimiter: delim,
|
delimiter: delim,
|
||||||
out_delimeter: out_delim,
|
out_delimiter: out_delim,
|
||||||
only_delimited,
|
only_delimited,
|
||||||
zero_terminated,
|
zero_terminated,
|
||||||
},
|
},
|
||||||
|
@ -513,7 +511,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
ranges,
|
ranges,
|
||||||
FieldOptions {
|
FieldOptions {
|
||||||
delimiter: "\t".to_owned(),
|
delimiter: "\t".to_owned(),
|
||||||
out_delimeter: out_delim,
|
out_delimiter: out_delim,
|
||||||
only_delimited,
|
only_delimited,
|
||||||
zero_terminated,
|
zero_terminated,
|
||||||
},
|
},
|
||||||
|
|
1
src/uu/cut/src/main.rs
Normal file
1
src/uu/cut/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_cut); // spell-checker:ignore procs uucore
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
// This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// (c) Rolf Morel <rolfmorel@gmail.com>
|
||||||
* (c) Rolf Morel <rolfmorel@gmail.com>
|
//
|
||||||
*
|
// For the full copyright and license information, please view the LICENSE
|
||||||
* For the full copyright and license information, please view the LICENSE
|
// file that was distributed with this source code.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
// spell-checker:ignore (ToDO) inval
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/*
|
// This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// (c) Rolf Morel <rolfmorel@gmail.com>
|
||||||
* (c) Rolf Morel <rolfmorel@gmail.com>
|
//
|
||||||
*
|
// For the full copyright and license information, please view the LICENSE
|
||||||
* For the full copyright and license information, please view the LICENSE
|
// file that was distributed with this source code.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Searcher<'a> {
|
pub struct Searcher<'a> {
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
[package]
|
[package]
|
||||||
name = "date"
|
name = "uu_date"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "date ~ (uutils) display or set the current time"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/date"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_date"
|
|
||||||
path = "src/date.rs"
|
path = "src/date.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
clap = "2.32"
|
clap = "2.32"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "date"
|
name = "date"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
#![crate_name = "uu_date"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Anthony Deschamps <anthony.j.deschamps@gmail.com>
|
||||||
|
// (c) Sylvestre Ledru <sylvestre@debian.org>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (format) MMDDhhmm
|
||||||
* This file is part of the uutils coreutils package.
|
// spell-checker:ignore (ToDO) DATEFILE
|
||||||
*
|
|
||||||
* (c) Anthony Deschamps <anthony.j.deschamps@gmail.com>
|
|
||||||
* (c) Sylvestre Ledru <sylvestre@debian.org>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
|
|
||||||
|
|
1
src/uu/date/src/main.rs
Normal file
1
src/uu/date/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_date); // spell-checker:ignore procs uucore
|
|
@ -1,24 +1,29 @@
|
||||||
[package]
|
[package]
|
||||||
name = "df"
|
name = "uu_df"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "df ~ (uutils) display file system information"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/df"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_df"
|
|
||||||
path = "src/df.rs"
|
path = "src/df.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.32"
|
clap = "2.32"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
number_prefix = "0.2"
|
number_prefix = "0.2"
|
||||||
uucore = "0.0.1"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
kernel32-sys = "0.2"
|
winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "winerror"] }
|
||||||
winapi = { version = "0.3", features = ["handleapi", "winerror"] }
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "df"
|
name = "df"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
#![crate_name = "uu_df"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Fangxu Hu <framlog@gmail.com>
|
||||||
|
// (c) Sylvestre Ledru <sylvestre@debian.org>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE file
|
||||||
|
// that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) mountinfo mtab BLOCKSIZE getmntinfo fobj mptr noatime Iused overmounted
|
||||||
* This file is part of the uutils coreutils package.
|
// spell-checker:ignore (libc/fs) asyncreads asyncwrites autofs bavail bfree bsize charspare cifs debugfs devfs devpts ffree frsize fsid fstypename fusectl inode inodes iosize kernfs mntbufp mntfromname mntonname mqueue namemax pipefs smbfs statfs statvfs subfs syncreads syncwrites sysfs wcslen
|
||||||
*
|
|
||||||
* (c) Fangxu Hu <framlog@gmail.com>
|
|
||||||
* (c) Sylvestre Ledru <sylvestre@debian.org>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE file
|
|
||||||
* that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
@ -17,16 +16,16 @@ extern crate number_prefix;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
|
||||||
#[cfg(windows)]
|
use clap::{App, Arg};
|
||||||
extern crate kernel32;
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use kernel32::{
|
use winapi::um::errhandlingapi::GetLastError;
|
||||||
FindFirstVolumeW, FindNextVolumeW, FindVolumeClose, GetDriveTypeW, GetLastError,
|
#[cfg(windows)]
|
||||||
GetVolumeInformationW, GetVolumePathNamesForVolumeNameW, QueryDosDeviceW,
|
use winapi::um::fileapi::{
|
||||||
|
FindFirstVolumeW, FindNextVolumeW, FindVolumeClose, GetDriveTypeW, GetVolumeInformationW,
|
||||||
|
GetVolumePathNamesForVolumeNameW, QueryDosDeviceW,
|
||||||
};
|
};
|
||||||
|
|
||||||
use number_prefix::{binary_prefix, decimal_prefix, PrefixNames, Prefixed, Standalone};
|
use number_prefix::{binary_prefix, decimal_prefix, PrefixNames, Prefixed, Standalone};
|
||||||
|
|
1
src/uu/df/src/main.rs
Normal file
1
src/uu/df/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_df); // spell-checker:ignore procs uucore
|
|
@ -1,18 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dircolors"
|
name = "uu_dircolors"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "dircolors ~ (uutils) display commands to set LS_COLORS"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/dircolors"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_dircolors"
|
|
||||||
path = "src/dircolors.rs"
|
path = "src/dircolors.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glob = "0.3.0"
|
glob = "0.3.0"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "dircolors"
|
name = "dircolors"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// spell-checker:ignore (ToDO) EIGHTBIT ETERM MULTIHARDLINK cpio dtterm jfbterm konsole kterm mlterm rmvb rxvt stat'able svgz tmux webm xspf
|
||||||
|
|
||||||
pub const INTERNAL_DB: &str = r#"# Configuration file for dircolors, a utility to help you set the
|
pub const INTERNAL_DB: &str = r#"# Configuration file for dircolors, a utility to help you set the
|
||||||
# LS_COLORS environment variable used by GNU ls with the --color option.
|
# LS_COLORS environment variable used by GNU ls with the --color option.
|
||||||
# Copyright (C) 1996-2016 Free Software Foundation, Inc.
|
# Copyright (C) 1996-2016 Free Software Foundation, Inc.
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#![crate_name = "uu_dircolors"]
|
|
||||||
|
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
// (c) Jian Zeng <anonymousknight96@gmail.com>
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
|
||||||
|
// spell-checker:ignore (ToDO) clrtoeol dircolors eightbit endcode fnmatch leftcode multihardlink rightcode setenv sgid suid
|
||||||
|
|
||||||
extern crate glob;
|
extern crate glob;
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ static LONG_HELP: &str = "
|
||||||
";
|
";
|
||||||
|
|
||||||
mod colors;
|
mod colors;
|
||||||
use colors::INTERNAL_DB;
|
use self::colors::INTERNAL_DB;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub enum OutputFmt {
|
pub enum OutputFmt {
|
||||||
|
@ -56,7 +55,7 @@ pub fn guess_syntax() -> OutputFmt {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optflag("b", "sh", "output Bourne shell code to set LS_COLORS")
|
.optflag("b", "sh", "output Bourne shell code to set LS_COLORS")
|
||||||
.optflag(
|
.optflag(
|
||||||
"",
|
"",
|
||||||
|
@ -74,7 +73,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
|| matches.opt_present("bourne-shell"))
|
|| matches.opt_present("bourne-shell"))
|
||||||
&& matches.opt_present("print-database")
|
&& matches.opt_present("print-database")
|
||||||
{
|
{
|
||||||
disp_err!(
|
show_usage_error!(
|
||||||
"the options to output dircolors' internal database and\nto select a shell \
|
"the options to output dircolors' internal database and\nto select a shell \
|
||||||
syntax are mutually exclusive"
|
syntax are mutually exclusive"
|
||||||
);
|
);
|
||||||
|
@ -83,7 +82,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
|
|
||||||
if matches.opt_present("print-database") {
|
if matches.opt_present("print-database") {
|
||||||
if !matches.free.is_empty() {
|
if !matches.free.is_empty() {
|
||||||
disp_err!(
|
show_usage_error!(
|
||||||
"extra operand ‘{}’\nfile operands cannot be combined with \
|
"extra operand ‘{}’\nfile operands cannot be combined with \
|
||||||
--print-database (-p)",
|
--print-database (-p)",
|
||||||
matches.free[0]
|
matches.free[0]
|
||||||
|
@ -116,7 +115,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
result = parse(INTERNAL_DB.lines(), out_format, "")
|
result = parse(INTERNAL_DB.lines(), out_format, "")
|
||||||
} else {
|
} else {
|
||||||
if matches.free.len() > 1 {
|
if matches.free.len() > 1 {
|
||||||
disp_err!("extra operand ‘{}’", matches.free[1]);
|
show_usage_error!("extra operand ‘{}’", matches.free[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
match File::open(matches.free[0].as_str()) {
|
match File::open(matches.free[0].as_str()) {
|
||||||
|
|
1
src/uu/dircolors/src/main.rs
Normal file
1
src/uu/dircolors/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_dircolors); // spell-checker:ignore procs uucore
|
|
@ -1,18 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dirname"
|
name = "uu_dirname"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "dirname ~ (uutils) display parent directory of PATHNAME"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/dirname"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_dirname"
|
|
||||||
path = "src/dirname.rs"
|
path = "src/dirname.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "dirname"
|
name = "dirname"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
#![crate_name = "uu_dirname"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
/*
|
// (c) Derek Chiang <derekchiang93@gmail.com>
|
||||||
* This file is part of the uutils coreutils package.
|
//
|
||||||
*
|
// For the full copyright and license information, please view the LICENSE
|
||||||
* (c) Derek Chiang <derekchiang93@gmail.com>
|
// file that was distributed with this source code.
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -24,7 +20,7 @@ static LONG_HELP: &str = "
|
||||||
";
|
";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optflag("z", "zero", "separate output with NUL rather than newline")
|
.optflag("z", "zero", "separate output with NUL rather than newline")
|
||||||
.parse(args);
|
.parse(args);
|
||||||
|
|
||||||
|
|
1
src/uu/dirname/src/main.rs
Normal file
1
src/uu/dirname/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_dirname); // spell-checker:ignore procs uucore
|
|
@ -1,18 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "du"
|
name = "uu_du"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "du ~ (uutils) display disk usage"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/du"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_du"
|
|
||||||
path = "src/du.rs"
|
path = "src/du.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
time = "0.1.40"
|
time = "0.1.40"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "du"
|
name = "du"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#![crate_name = "uu_du"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Derek Chiang <derekchiang93@gmail.com>
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) BLOCKSIZE inode inodes ment strs
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Derek Chiang <derekchiang93@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
{0} [OPTION]... --files0-from=F",
|
{0} [OPTION]... --files0-from=F",
|
||||||
NAME
|
NAME
|
||||||
);
|
);
|
||||||
let matches = new_coreopts!(&syntax, SUMMARY, LONG_HELP)
|
let matches = app!(&syntax, SUMMARY, LONG_HELP)
|
||||||
// In task
|
// In task
|
||||||
.optflag(
|
.optflag(
|
||||||
"a",
|
"a",
|
||||||
|
|
1
src/uu/du/src/main.rs
Normal file
1
src/uu/du/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_du); // spell-checker:ignore procs uucore
|
|
@ -1,17 +1,23 @@
|
||||||
[package]
|
[package]
|
||||||
name = "echo"
|
name = "uu_echo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "echo ~ (uutils) display TEXT"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/echo"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_echo"
|
|
||||||
path = "src/echo.rs"
|
path = "src/echo.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "echo"
|
name = "echo"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
#![crate_name = "uu_echo"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
/*
|
// (c) Derek Chiang <derekchiang93@gmail.com>
|
||||||
* This file is part of the uutils coreutils package.
|
// (c) Christopher Brown <ccbrown112@gmail.com>
|
||||||
*
|
//
|
||||||
* (c) Derek Chiang <derekchiang93@gmail.com>
|
// For the full copyright and license information, please view the LICENSE
|
||||||
* (c) Christopher Brown <ccbrown112@gmail.com>
|
// file that was distributed with this source code.
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -107,7 +103,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, HELP)
|
let matches = app!(SYNTAX, SUMMARY, HELP)
|
||||||
.optflag("n", "", "do not output the trailing newline")
|
.optflag("n", "", "do not output the trailing newline")
|
||||||
.optflag("e", "", "enable interpretation of backslash escapes")
|
.optflag("e", "", "enable interpretation of backslash escapes")
|
||||||
.optflag(
|
.optflag(
|
||||||
|
|
1
src/uu/echo/src/main.rs
Normal file
1
src/uu/echo/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_echo); // spell-checker:ignore procs uucore
|
16
src/uu/env/Cargo.toml
vendored
16
src/uu/env/Cargo.toml
vendored
|
@ -1,22 +1,26 @@
|
||||||
[package]
|
[package]
|
||||||
name = "env"
|
name = "uu_env"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = ["uutils developers"]
|
authors = ["uutils developers"]
|
||||||
description = "Set each NAME to VALUE in the environment and run COMMAND"
|
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/env"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_env"
|
|
||||||
path = "src/env.rs"
|
path = "src/env.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33"
|
clap = "2.33"
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
rust-ini = "0.13.0"
|
rust-ini = "0.13.0"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "env"
|
name = "env"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
17
src/uu/env/src/env.rs
vendored
17
src/uu/env/src/env.rs
vendored
|
@ -1,15 +1,14 @@
|
||||||
#![crate_name = "uu_env"]
|
// This file is part of the uutils coreutils package.
|
||||||
/*
|
//
|
||||||
* This file is part of the uutils coreutils package.
|
// (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*
|
//
|
||||||
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
// For the full copyright and license information, please view the LICENSE
|
||||||
*
|
// file that was distributed with this source code.
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* last synced with: env (GNU coreutils) 8.13 */
|
/* last synced with: env (GNU coreutils) 8.13 */
|
||||||
|
|
||||||
|
// spell-checker:ignore (ToDO) execvp progname subcommand subcommands unsets
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
|
|
1
src/uu/env/src/main.rs
vendored
Normal file
1
src/uu/env/src/main.rs
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_env); // spell-checker:ignore procs uucore
|
|
@ -1,19 +1,25 @@
|
||||||
[package]
|
[package]
|
||||||
name = "expand"
|
name = "uu_expand"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "expand ~ (uutils) convert input tabs to spaces"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/expand"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_expand"
|
|
||||||
path = "src/expand.rs"
|
path = "src/expand.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
getopts = "0.2.18"
|
getopts = "0.2.18"
|
||||||
unicode-width = "0.1.5"
|
unicode-width = "0.1.5"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "expand"
|
name = "expand"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
#![crate_name = "uu_expand"]
|
// This file is part of the uutils coreutils package.
|
||||||
|
//
|
||||||
|
// (c) Virgile Andreani <virgile.andreani@anbuco.fr>
|
||||||
|
// (c) kwantam <kwantam@gmail.com>
|
||||||
|
// * 2015-04-28 ~ updated to work with both UTF-8 and non-UTF-8 encodings
|
||||||
|
//
|
||||||
|
// For the full copyright and license information, please view the LICENSE
|
||||||
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
/*
|
// spell-checker:ignore (ToDO) ctype cwidth iflag nbytes nspaces nums tspaces uflag
|
||||||
* This file is part of the uutils coreutils package.
|
|
||||||
*
|
|
||||||
* (c) Virgile Andreani <virgile.andreani@anbuco.fr>
|
|
||||||
* (c) kwantam <kwantam@gmail.com>
|
|
||||||
* 20150428 updated to work with both UTF-8 and non-UTF-8 encodings
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate unicode_width;
|
extern crate unicode_width;
|
||||||
|
@ -103,7 +101,7 @@ impl Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP)
|
||||||
.optflag("i", "initial", "do not convert tabs after non blanks")
|
.optflag("i", "initial", "do not convert tabs after non blanks")
|
||||||
.optopt(
|
.optopt(
|
||||||
"t",
|
"t",
|
||||||
|
|
1
src/uu/expand/src/main.rs
Normal file
1
src/uu/expand/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_expand); // spell-checker:ignore procs uucore
|
|
@ -1,19 +1,25 @@
|
||||||
[package]
|
[package]
|
||||||
name = "expr"
|
name = "uu_expr"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
build = "../../common/mkmain.rs"
|
description = "expr ~ (uutils) display the value of EXPRESSION"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/expr"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_expr"
|
|
||||||
path = "src/expr.rs"
|
path = "src/expr.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
onig = "~4.3.2"
|
onig = "~4.3.2"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "expr"
|
name = "expr"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
#![crate_name = "uu_expr"]
|
//* This file is part of the uutils coreutils package.
|
||||||
|
//*
|
||||||
/*
|
//* (c) Roman Gafiyatullin <r.gafiyatullin@me.com>
|
||||||
* This file is part of the uutils coreutils package.
|
//*
|
||||||
*
|
//* For the full copyright and license information, please view the LICENSE
|
||||||
* (c) Roman Gafiyatullin <r.gafiyatullin@me.com>
|
//* file that was distributed with this source code.
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate onig;
|
extern crate onig;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
1
src/uu/expr/src/main.rs
Normal file
1
src/uu/expr/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_expr); // spell-checker:ignore procs uucore
|
|
@ -1,19 +1,20 @@
|
||||||
/*
|
//* This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//*
|
||||||
*
|
//* (c) Roman Gafiyatullin <r.gafiyatullin@me.com>
|
||||||
* (c) Roman Gafiyatullin <r.gafiyatullin@me.com>
|
//*
|
||||||
*
|
//* For the full copyright and license information, please view the LICENSE
|
||||||
* For the full copyright and license information, please view the LICENSE
|
//* file that was distributed with this source code.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//!
|
//!
|
||||||
//! Here we employ shunting-yard algorithm for building AST from tokens according to operators' precedence and associativeness.
|
//! Here we employ shunting-yard algorithm for building AST from tokens according to operators' precedence and associative-ness.
|
||||||
//! * https://en.wikipedia.org/wiki/Shunting-yard_algorithm
|
//! * https://en.wikipedia.org/wiki/Shunting-yard_algorithm
|
||||||
//!
|
//!
|
||||||
|
|
||||||
|
// spell-checker:ignore (ToDO) binop binops ints paren prec
|
||||||
|
|
||||||
use onig::{Regex, RegexOptions, Syntax};
|
use onig::{Regex, RegexOptions, Syntax};
|
||||||
use tokens::Token;
|
|
||||||
|
use crate::tokens::Token;
|
||||||
|
|
||||||
type TokenStack = Vec<(usize, Token)>;
|
type TokenStack = Vec<(usize, Token)>;
|
||||||
pub type OperandsList = Vec<Box<ASTNode>>;
|
pub type OperandsList = Vec<Box<ASTNode>>;
|
||||||
|
@ -200,7 +201,10 @@ pub fn tokens_to_ast(
|
||||||
maybe_dump_rpn(&out_stack);
|
maybe_dump_rpn(&out_stack);
|
||||||
let result = ast_from_rpn(&mut out_stack);
|
let result = ast_from_rpn(&mut out_stack);
|
||||||
if !out_stack.is_empty() {
|
if !out_stack.is_empty() {
|
||||||
Err("syntax error (fist RPN token does not represent expression AST's root)".to_owned())
|
Err(
|
||||||
|
"syntax error (first RPN token does not represent the root of the expression AST)"
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
maybe_dump_ast(&result);
|
maybe_dump_ast(&result);
|
||||||
result
|
result
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/*
|
//* This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
//*
|
||||||
*
|
//* (c) Roman Gafiyatullin <r.gafiyatullin@me.com>
|
||||||
* (c) Roman Gafiyatullin <r.gafiyatullin@me.com>
|
//*
|
||||||
*
|
//* For the full copyright and license information, please view the LICENSE
|
||||||
* For the full copyright and license information, please view the LICENSE
|
//* file that was distributed with this source code.
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//!
|
//!
|
||||||
//! The following tokens are present in the expr grammar:
|
//! The following tokens are present in the expr grammar:
|
||||||
|
@ -18,6 +16,8 @@
|
||||||
//! Hence all we need is to map the strings into the Token structures, except for some ugly fiddling with +-escaping.
|
//! Hence all we need is to map the strings into the Token structures, except for some ugly fiddling with +-escaping.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
|
// spell-checker:ignore (ToDO) paren
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Token {
|
pub enum Token {
|
||||||
Value {
|
Value {
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
[package]
|
[package]
|
||||||
name = "factor"
|
name = "uu_factor"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = ["uutils developers"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
description = "factor ~ (uutils) display the prime factors of each NUMBER"
|
||||||
|
|
||||||
|
homepage = "https://github.com/uutils/coreutils"
|
||||||
|
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/"
|
||||||
|
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "uu_factor"
|
|
||||||
path = "src/factor.rs"
|
path = "src/factor.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.5"
|
rand = "0.5"
|
||||||
uucore = "0.0.2"
|
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "factor"
|
name = "factor"
|
||||||
path = "../../common/uumain.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
/*
|
// * This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
// *
|
||||||
*
|
// * (c) kwantam <kwantam@gmail.com>
|
||||||
* (c) kwantam <kwantam@gmail.com>
|
// *
|
||||||
*
|
// * For the full copyright and license information, please view the LICENSE file
|
||||||
* For the full copyright and license information, please view the LICENSE file
|
// * that was distributed with this source code.
|
||||||
* that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//! Generate a table of the multiplicative inverses of p_i mod 2^64
|
//! Generate a table of the multiplicative inverses of p_i mod 2^64
|
||||||
//! for the first 1027 odd primes (all 13 bit and smaller primes).
|
//! for the first 1027 odd primes (all 13 bit and smaller primes).
|
||||||
//! You can supply a commandline argument to override the default
|
//! You can supply a command line argument to override the default
|
||||||
//! value of 1027 for the number of entries in the table.
|
//! value of 1027 for the number of entries in the table.
|
||||||
//!
|
//!
|
||||||
//! 2 has no multiplicative inverse mode 2^64 because 2 | 2^64,
|
//! 2 has no multiplicative inverse mode 2^64 because 2 | 2^64,
|
||||||
//! and in any case divisibility by two is trivial by checking the LSB.
|
//! and in any case divisibility by two is trivial by checking the LSB.
|
||||||
|
|
||||||
|
// spell-checker:ignore (ToDO) invs newr newrp newtp outstr
|
||||||
|
|
||||||
#![cfg_attr(test, allow(dead_code))]
|
#![cfg_attr(test, allow(dead_code))]
|
||||||
|
|
||||||
use sieve::Sieve;
|
|
||||||
use std::env::{self, args};
|
use std::env::{self, args};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -25,6 +24,8 @@ use std::num::Wrapping;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::u64::MAX as MAX_U64;
|
use std::u64::MAX as MAX_U64;
|
||||||
|
|
||||||
|
use self::sieve::Sieve;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use miller_rabin::is_prime;
|
use miller_rabin::is_prime;
|
||||||
|
|
||||||
|
@ -34,9 +35,6 @@ mod numeric;
|
||||||
|
|
||||||
mod sieve;
|
mod sieve;
|
||||||
|
|
||||||
#[path = "../../common/mkmain.rs"]
|
|
||||||
mod mkmain;
|
|
||||||
|
|
||||||
// extended Euclid algorithm
|
// extended Euclid algorithm
|
||||||
// precondition: a does not divide 2^64
|
// precondition: a does not divide 2^64
|
||||||
fn inv_mod_u64(a: u64) -> Option<u64> {
|
fn inv_mod_u64(a: u64) -> Option<u64> {
|
||||||
|
@ -74,8 +72,6 @@ fn inv_mod_u64(a: u64) -> Option<u64> {
|
||||||
|
|
||||||
#[cfg_attr(test, allow(dead_code))]
|
#[cfg_attr(test, allow(dead_code))]
|
||||||
fn main() {
|
fn main() {
|
||||||
mkmain::main();
|
|
||||||
|
|
||||||
let out_dir = env::var("OUT_DIR").unwrap();
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
let mut file = File::create(&Path::new(&out_dir).join("prime_table.rs")).unwrap();
|
let mut file = File::create(&Path::new(&out_dir).join("prime_table.rs")).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
// * This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
// *
|
||||||
*
|
// * (c) kwantam <kwantam@gmail.com>
|
||||||
* (c) kwantam <kwantam@gmail.com>
|
// *
|
||||||
*
|
// * For the full copyright and license information, please view the LICENSE file
|
||||||
* For the full copyright and license information, please view the LICENSE file
|
// * that was distributed with this source code.
|
||||||
* that was distributed with this source code.
|
|
||||||
*/
|
// spell-checker:ignore (ToDO) filts, minidx, minkey paridx
|
||||||
|
|
||||||
use std::iter::{Chain, Cycle, Map};
|
use std::iter::{Chain, Cycle, Map};
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#![crate_name = "uu_factor"]
|
// * This file is part of the uutils coreutils package.
|
||||||
|
// *
|
||||||
/*
|
// * (c) T. Jameson Little <t.jameson.little@gmail.com>
|
||||||
* This file is part of the uutils coreutils package.
|
// * (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com>
|
||||||
*
|
// * * 2015-02-23 ~ added Pollard rho method implementation
|
||||||
* (c) T. Jameson Little <t.jameson.little@gmail.com>
|
// * (c) kwantam <kwantam@gmail.com>
|
||||||
* (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com>
|
// * * 2015-04-29 ~ sped up trial division by adding table of prime inverses
|
||||||
* 20150223 added Pollard rho method implementation
|
// *
|
||||||
* (c) kwantam <kwantam@gmail.com>
|
// * For the full copyright and license information, please view the LICENSE file
|
||||||
* 20150429 sped up trial division by adding table of prime inverses
|
// * that was distributed with this source code.
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE file
|
|
||||||
* that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
|
@ -120,7 +116,7 @@ fn print_factors_str(num_str: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
let matches = app!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
||||||
|
|
||||||
if matches.free.is_empty() {
|
if matches.free.is_empty() {
|
||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
|
|
1
src/uu/factor/src/main.rs
Normal file
1
src/uu/factor/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uucore_procs::main!(uu_factor); // spell-checker:ignore procs uucore
|
|
@ -1,3 +1,5 @@
|
||||||
|
// spell-checker:ignore (URL) appspot
|
||||||
|
|
||||||
use crate::numeric::*;
|
use crate::numeric::*;
|
||||||
|
|
||||||
// Small set of bases for the Miller-Rabin prime test, valid for all 64b integers;
|
// Small set of bases for the Miller-Rabin prime test, valid for all 64b integers;
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
/*
|
// * This file is part of the uutils coreutils package.
|
||||||
* This file is part of the uutils coreutils package.
|
// *
|
||||||
*
|
// * (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com>
|
||||||
* (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com>
|
// * (c) kwantam <kwantam@gmail.com>
|
||||||
* (c) kwantam <kwantam@gmail.com>
|
// * * 20150507 ~ added big_ routines to prevent overflow when num > 2^63
|
||||||
* 20150507 added big_ routines to prevent overflow when num > 2^63
|
// *
|
||||||
*
|
// * For the full copyright and license information, please view the LICENSE file
|
||||||
* For the full copyright and license information, please view the LICENSE file
|
// * that was distributed with this source code.
|
||||||
* that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use std::mem::swap;
|
use std::mem::swap;
|
||||||
use std::num::Wrapping;
|
use std::num::Wrapping;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use crate::miller_rabin::Result::*;
|
|
||||||
use crate::{miller_rabin, Factors};
|
|
||||||
use numeric::*;
|
|
||||||
use rand::distributions::{Distribution, Uniform};
|
use rand::distributions::{Distribution, Uniform};
|
||||||
use rand::rngs::SmallRng;
|
use rand::rngs::SmallRng;
|
||||||
use rand::{thread_rng, SeedableRng};
|
use rand::{thread_rng, SeedableRng};
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
|
use crate::miller_rabin::Result::*;
|
||||||
|
use crate::numeric::*;
|
||||||
|
use crate::{miller_rabin, Factors};
|
||||||
|
|
||||||
fn find_divisor<A: Arithmetic>(n: u64) -> u64 {
|
fn find_divisor<A: Arithmetic>(n: u64) -> u64 {
|
||||||
#![allow(clippy::many_single_char_names)]
|
#![allow(clippy::many_single_char_names)]
|
||||||
let mut rand = {
|
let mut rand = {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use crate::Factors;
|
// spell-checker: ignore (ToDO) INVS
|
||||||
|
|
||||||
use std::num::Wrapping;
|
use std::num::Wrapping;
|
||||||
|
|
||||||
|
use crate::Factors;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/prime_table.rs"));
|
include!(concat!(env!("OUT_DIR"), "/prime_table.rs"));
|
||||||
|
|
||||||
pub(crate) fn factor(mut num: u64) -> (Factors, u64) {
|
pub(crate) fn factor(mut num: u64) -> (Factors, u64) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue