diff --git a/Cargo.toml b/Cargo.toml index cbb91bf32..885bcf071 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ version = "0.0.9" authors = ["uutils developers"] license = "MIT" description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust" +default-run = "coreutils" homepage = "https://github.com/uutils/coreutils" repository = "https://github.com/uutils/coreutils" diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..0b2699ecb --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,2 @@ +book +_generated \ No newline at end of file diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html new file mode 100644 index 000000000..80098ad2d --- /dev/null +++ b/docs/CONTRIBUTING.html @@ -0,0 +1,185 @@ + + + + + + Contributing - Uutils Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + +
+
+

Contributing

+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 000000000..854139a31 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1 @@ +# Contributing diff --git a/docs/arch.rst b/docs/arch.rst deleted file mode 100644 index 66b516159..000000000 --- a/docs/arch.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. print machine hardware name - -==== -arch -==== - -.. FIXME: this needs to be autogenerated somehow - --------- -Synopsis --------- - -``arch`` [OPTION]... - ------------ -Description ------------ - -``arch`` is an alias for ``uname -m``. They both print the machine hardware -name. - -An exit code of zero indicates success, whereas anything else means failure. -For this program, a non-zero exit code generally means the user provided -invalid options. - --h, --help print a help menu for this program displaying accepted - options and arguments --v, --version print the version number of this program diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 000000000..10e64f3c9 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,9 @@ +[book] +authors = ["uutils contributors"] +language = "en" +multilingual = false +src = "src" +title = "Uutils Documentation" + +[output.html] +git-repository-url = "https://github.com/rust-lang/cargo/tree/master/src/doc/src" \ No newline at end of file diff --git a/docs/create_docs.py b/docs/create_docs.py new file mode 100644 index 000000000..b07b851fa --- /dev/null +++ b/docs/create_docs.py @@ -0,0 +1,20 @@ +# Simple script to create the correct SUMMARY.md and other files +# for the mdbook documentation. +# Note: This will overwrite the existing files! + +import os + +with open('src/utils/index.md', 'w') as index: + with open('src/SUMMARY.md', 'w') as summary: + summary.write("# Summary\n\n") + summary.write("* [Introduction](introduction.md)\n") + summary.write("* [Contributing](contributing.md)\n") + summary.write("* [Utils](utils/index.md)\n") + index.write("# Utils\n\n") + for d in sorted(os.listdir('../src/uu')): + with open(f"src/utils/{d}.md", 'w') as f: + f.write(f"# {d}\n\n") + f.write(f"{{{{ #include ../../_generated/{d}-help.md }}}}\n") + print(f"Created docs/src/utils/{d}.md") + summary.write(f" * [{d}](utils/{d}.md)\n") + index.write(f"* [{d}](./{d}.md)\n") \ No newline at end of file diff --git a/docs/docs/.gitignore b/docs/docs/.gitignore deleted file mode 100644 index 7585238ef..000000000 --- a/docs/docs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -book diff --git a/docs/docs/book.toml b/docs/docs/book.toml deleted file mode 100644 index fe32ddf98..000000000 --- a/docs/docs/book.toml +++ /dev/null @@ -1,6 +0,0 @@ -[book] -authors = ["Terts Diepraam"] -language = "en" -multilingual = false -src = "src" -title = "Uutils Documentation" diff --git a/docs/docs/src/SUMMARY.md b/docs/docs/src/SUMMARY.md deleted file mode 100644 index 7390c8289..000000000 --- a/docs/docs/src/SUMMARY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Summary - -- [Chapter 1](./chapter_1.md) diff --git a/docs/docs/src/chapter_1.md b/docs/docs/src/chapter_1.md deleted file mode 100644 index b743fda35..000000000 --- a/docs/docs/src/chapter_1.md +++ /dev/null @@ -1 +0,0 @@ -# Chapter 1 diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 7f782b12a..000000000 --- a/docs/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -.. uutils documentation master file, created by - sphinx-quickstart on Tue Dec 5 23:20:18 2017. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -.. - spell-checker:ignore (directives) genindex maxdepth modindex toctree ; (misc) quickstart - -Welcome to uutils' documentation! -================================= - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - arch - uutils - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 000000000..bc595000a --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,105 @@ +# Summary + +* [Introduction](introduction.md) +* [Contributing](contributing.md) +* [Utils](utils/index.md) + * [arch](utils/arch.md) + * [base32](utils/base32.md) + * [base64](utils/base64.md) + * [basename](utils/basename.md) + * [basenc](utils/basenc.md) + * [cat](utils/cat.md) + * [chcon](utils/chcon.md) + * [chgrp](utils/chgrp.md) + * [chmod](utils/chmod.md) + * [chown](utils/chown.md) + * [chroot](utils/chroot.md) + * [cksum](utils/cksum.md) + * [comm](utils/comm.md) + * [cp](utils/cp.md) + * [csplit](utils/csplit.md) + * [cut](utils/cut.md) + * [date](utils/date.md) + * [dd](utils/dd.md) + * [df](utils/df.md) + * [dircolors](utils/dircolors.md) + * [dirname](utils/dirname.md) + * [du](utils/du.md) + * [echo](utils/echo.md) + * [env](utils/env.md) + * [expand](utils/expand.md) + * [expr](utils/expr.md) + * [factor](utils/factor.md) + * [false](utils/false.md) + * [fmt](utils/fmt.md) + * [fold](utils/fold.md) + * [groups](utils/groups.md) + * [hashsum](utils/hashsum.md) + * [head](utils/head.md) + * [hostid](utils/hostid.md) + * [hostname](utils/hostname.md) + * [id](utils/id.md) + * [install](utils/install.md) + * [join](utils/join.md) + * [kill](utils/kill.md) + * [link](utils/link.md) + * [ln](utils/ln.md) + * [logname](utils/logname.md) + * [ls](utils/ls.md) + * [mkdir](utils/mkdir.md) + * [mkfifo](utils/mkfifo.md) + * [mknod](utils/mknod.md) + * [mktemp](utils/mktemp.md) + * [more](utils/more.md) + * [mv](utils/mv.md) + * [nice](utils/nice.md) + * [nl](utils/nl.md) + * [nohup](utils/nohup.md) + * [nproc](utils/nproc.md) + * [numfmt](utils/numfmt.md) + * [od](utils/od.md) + * [paste](utils/paste.md) + * [pathchk](utils/pathchk.md) + * [pinky](utils/pinky.md) + * [pr](utils/pr.md) + * [printenv](utils/printenv.md) + * [printf](utils/printf.md) + * [ptx](utils/ptx.md) + * [pwd](utils/pwd.md) + * [readlink](utils/readlink.md) + * [realpath](utils/realpath.md) + * [relpath](utils/relpath.md) + * [rm](utils/rm.md) + * [rmdir](utils/rmdir.md) + * [runcon](utils/runcon.md) + * [seq](utils/seq.md) + * [shred](utils/shred.md) + * [shuf](utils/shuf.md) + * [sleep](utils/sleep.md) + * [sort](utils/sort.md) + * [split](utils/split.md) + * [stat](utils/stat.md) + * [stdbuf](utils/stdbuf.md) + * [sum](utils/sum.md) + * [sync](utils/sync.md) + * [tac](utils/tac.md) + * [tail](utils/tail.md) + * [tee](utils/tee.md) + * [test](utils/test.md) + * [timeout](utils/timeout.md) + * [touch](utils/touch.md) + * [tr](utils/tr.md) + * [true](utils/true.md) + * [truncate](utils/truncate.md) + * [tsort](utils/tsort.md) + * [tty](utils/tty.md) + * [uname](utils/uname.md) + * [unexpand](utils/unexpand.md) + * [uniq](utils/uniq.md) + * [unlink](utils/unlink.md) + * [uptime](utils/uptime.md) + * [users](utils/users.md) + * [wc](utils/wc.md) + * [who](utils/who.md) + * [whoami](utils/whoami.md) + * [yes](utils/yes.md) diff --git a/docs/src/contributing.md b/docs/src/contributing.md new file mode 100644 index 000000000..79ef4d13b --- /dev/null +++ b/docs/src/contributing.md @@ -0,0 +1 @@ +{{ #include ../../CONTRIBUTING.md }} \ No newline at end of file diff --git a/docs/src/introduction.md b/docs/src/introduction.md new file mode 100644 index 000000000..261205d34 --- /dev/null +++ b/docs/src/introduction.md @@ -0,0 +1,8 @@ +# Introduction + +uutils is an attempt at writing universal (as in cross-platform) CLI +utilities in [Rust](https://www.rust-lang.org). The source code is hosted +on [GitHub](https://github.com/uutils/coreutils). + +> Note: This manual is automatically generated from the source code and is +> a work in progress. \ No newline at end of file diff --git a/docs/src/utils/arch.md b/docs/src/utils/arch.md new file mode 100644 index 000000000..b0ca5c7e9 --- /dev/null +++ b/docs/src/utils/arch.md @@ -0,0 +1,3 @@ +# arch + +{{ #include ../../_generated/arch-help.md }} diff --git a/docs/src/utils/base32.md b/docs/src/utils/base32.md new file mode 100644 index 000000000..d79092b3d --- /dev/null +++ b/docs/src/utils/base32.md @@ -0,0 +1,3 @@ +# base32 + +{{ #include ../../_generated/base32-help.md }} diff --git a/docs/src/utils/base64.md b/docs/src/utils/base64.md new file mode 100644 index 000000000..6864531f8 --- /dev/null +++ b/docs/src/utils/base64.md @@ -0,0 +1,3 @@ +# base64 + +{{ #include ../../_generated/base64-help.md }} diff --git a/docs/src/utils/basename.md b/docs/src/utils/basename.md new file mode 100644 index 000000000..9a20edfd2 --- /dev/null +++ b/docs/src/utils/basename.md @@ -0,0 +1,3 @@ +# basename + +{{ #include ../../_generated/basename-help.md }} diff --git a/docs/src/utils/basenc.md b/docs/src/utils/basenc.md new file mode 100644 index 000000000..bc6721be8 --- /dev/null +++ b/docs/src/utils/basenc.md @@ -0,0 +1,3 @@ +# basenc + +{{ #include ../../_generated/basenc-help.md }} diff --git a/docs/src/utils/cat.md b/docs/src/utils/cat.md new file mode 100644 index 000000000..e8a3f02e0 --- /dev/null +++ b/docs/src/utils/cat.md @@ -0,0 +1,3 @@ +# cat + +{{ #include ../../_generated/cat-help.md }} diff --git a/docs/src/utils/chcon.md b/docs/src/utils/chcon.md new file mode 100644 index 000000000..eb416b8d2 --- /dev/null +++ b/docs/src/utils/chcon.md @@ -0,0 +1,3 @@ +# chcon + +{{ #include ../../_generated/chcon-help.md }} diff --git a/docs/src/utils/chgrp.md b/docs/src/utils/chgrp.md new file mode 100644 index 000000000..5b40501a7 --- /dev/null +++ b/docs/src/utils/chgrp.md @@ -0,0 +1,3 @@ +# chgrp + +{{ #include ../../_generated/chgrp-help.md }} diff --git a/docs/src/utils/chmod.md b/docs/src/utils/chmod.md new file mode 100644 index 000000000..91ec83f1d --- /dev/null +++ b/docs/src/utils/chmod.md @@ -0,0 +1,3 @@ +# chmod + +{{ #include ../../_generated/chmod-help.md }} diff --git a/docs/src/utils/chown.md b/docs/src/utils/chown.md new file mode 100644 index 000000000..72a4a1141 --- /dev/null +++ b/docs/src/utils/chown.md @@ -0,0 +1,3 @@ +# chown + +{{ #include ../../_generated/chown-help.md }} diff --git a/docs/src/utils/chroot.md b/docs/src/utils/chroot.md new file mode 100644 index 000000000..603c1e948 --- /dev/null +++ b/docs/src/utils/chroot.md @@ -0,0 +1,3 @@ +# chroot + +{{ #include ../../_generated/chroot-help.md }} diff --git a/docs/src/utils/cksum.md b/docs/src/utils/cksum.md new file mode 100644 index 000000000..544452d53 --- /dev/null +++ b/docs/src/utils/cksum.md @@ -0,0 +1,3 @@ +# cksum + +{{ #include ../../_generated/cksum-help.md }} diff --git a/docs/src/utils/comm.md b/docs/src/utils/comm.md new file mode 100644 index 000000000..fe3aba9b6 --- /dev/null +++ b/docs/src/utils/comm.md @@ -0,0 +1,3 @@ +# comm + +{{ #include ../../_generated/comm-help.md }} diff --git a/docs/src/utils/cp.md b/docs/src/utils/cp.md new file mode 100644 index 000000000..10b002ec8 --- /dev/null +++ b/docs/src/utils/cp.md @@ -0,0 +1,3 @@ +# cp + +{{ #include ../../_generated/cp-help.md }} diff --git a/docs/src/utils/csplit.md b/docs/src/utils/csplit.md new file mode 100644 index 000000000..897a2edfc --- /dev/null +++ b/docs/src/utils/csplit.md @@ -0,0 +1,3 @@ +# csplit + +{{ #include ../../_generated/csplit-help.md }} diff --git a/docs/src/utils/cut.md b/docs/src/utils/cut.md new file mode 100644 index 000000000..fea0f8f32 --- /dev/null +++ b/docs/src/utils/cut.md @@ -0,0 +1,3 @@ +# cut + +{{ #include ../../_generated/cut-help.md }} diff --git a/docs/src/utils/date.md b/docs/src/utils/date.md new file mode 100644 index 000000000..1c6a49131 --- /dev/null +++ b/docs/src/utils/date.md @@ -0,0 +1,3 @@ +# date + +{{ #include ../../_generated/date-help.md }} diff --git a/docs/src/utils/dd.md b/docs/src/utils/dd.md new file mode 100644 index 000000000..d74426639 --- /dev/null +++ b/docs/src/utils/dd.md @@ -0,0 +1,3 @@ +# dd + +{{ #include ../../_generated/dd-help.md }} diff --git a/docs/src/utils/df.md b/docs/src/utils/df.md new file mode 100644 index 000000000..f22e899ec --- /dev/null +++ b/docs/src/utils/df.md @@ -0,0 +1,3 @@ +# df + +{{ #include ../../_generated/df-help.md }} diff --git a/docs/src/utils/dircolors.md b/docs/src/utils/dircolors.md new file mode 100644 index 000000000..fcec2dcf8 --- /dev/null +++ b/docs/src/utils/dircolors.md @@ -0,0 +1,3 @@ +# dircolors + +{{ #include ../../_generated/dircolors-help.md }} diff --git a/docs/src/utils/dirname.md b/docs/src/utils/dirname.md new file mode 100644 index 000000000..bc86fc999 --- /dev/null +++ b/docs/src/utils/dirname.md @@ -0,0 +1,3 @@ +# dirname + +{{ #include ../../_generated/dirname-help.md }} diff --git a/docs/src/utils/du.md b/docs/src/utils/du.md new file mode 100644 index 000000000..79236368c --- /dev/null +++ b/docs/src/utils/du.md @@ -0,0 +1,3 @@ +# du + +{{ #include ../../_generated/du-help.md }} diff --git a/docs/src/utils/echo.md b/docs/src/utils/echo.md new file mode 100644 index 000000000..fb86a0533 --- /dev/null +++ b/docs/src/utils/echo.md @@ -0,0 +1,3 @@ +# echo + +{{ #include ../../_generated/echo-help.md }} diff --git a/docs/src/utils/env.md b/docs/src/utils/env.md new file mode 100644 index 000000000..bbe828a81 --- /dev/null +++ b/docs/src/utils/env.md @@ -0,0 +1,3 @@ +# env + +{{ #include ../../_generated/env-help.md }} diff --git a/docs/src/utils/expand.md b/docs/src/utils/expand.md new file mode 100644 index 000000000..56c930b06 --- /dev/null +++ b/docs/src/utils/expand.md @@ -0,0 +1,3 @@ +# expand + +{{ #include ../../_generated/expand-help.md }} diff --git a/docs/src/utils/expr.md b/docs/src/utils/expr.md new file mode 100644 index 000000000..67914a6f3 --- /dev/null +++ b/docs/src/utils/expr.md @@ -0,0 +1,3 @@ +# expr + +{{ #include ../../_generated/expr-help.md }} diff --git a/docs/src/utils/factor.md b/docs/src/utils/factor.md new file mode 100644 index 000000000..a135ace83 --- /dev/null +++ b/docs/src/utils/factor.md @@ -0,0 +1,3 @@ +# factor + +{{ #include ../../_generated/factor-help.md }} diff --git a/docs/src/utils/false.md b/docs/src/utils/false.md new file mode 100644 index 000000000..0dcf26133 --- /dev/null +++ b/docs/src/utils/false.md @@ -0,0 +1,3 @@ +# false + +{{ #include ../../_generated/false-help.md }} diff --git a/docs/src/utils/fmt.md b/docs/src/utils/fmt.md new file mode 100644 index 000000000..10c987500 --- /dev/null +++ b/docs/src/utils/fmt.md @@ -0,0 +1,3 @@ +# fmt + +{{ #include ../../_generated/fmt-help.md }} diff --git a/docs/src/utils/fold.md b/docs/src/utils/fold.md new file mode 100644 index 000000000..8b41ed45d --- /dev/null +++ b/docs/src/utils/fold.md @@ -0,0 +1,3 @@ +# fold + +{{ #include ../../_generated/fold-help.md }} diff --git a/docs/src/utils/groups.md b/docs/src/utils/groups.md new file mode 100644 index 000000000..84c1e4dea --- /dev/null +++ b/docs/src/utils/groups.md @@ -0,0 +1,3 @@ +# groups + +{{ #include ../../_generated/groups-help.md }} diff --git a/docs/src/utils/hashsum.md b/docs/src/utils/hashsum.md new file mode 100644 index 000000000..76fe432db --- /dev/null +++ b/docs/src/utils/hashsum.md @@ -0,0 +1,3 @@ +# hashsum + +{{ #include ../../_generated/hashsum-help.md }} diff --git a/docs/src/utils/head.md b/docs/src/utils/head.md new file mode 100644 index 000000000..5b9a6dd75 --- /dev/null +++ b/docs/src/utils/head.md @@ -0,0 +1,3 @@ +# head + +{{ #include ../../_generated/head-help.md }} diff --git a/docs/src/utils/hostid.md b/docs/src/utils/hostid.md new file mode 100644 index 000000000..162557ce7 --- /dev/null +++ b/docs/src/utils/hostid.md @@ -0,0 +1,3 @@ +# hostid + +{{ #include ../../_generated/hostid-help.md }} diff --git a/docs/src/utils/hostname.md b/docs/src/utils/hostname.md new file mode 100644 index 000000000..24865db59 --- /dev/null +++ b/docs/src/utils/hostname.md @@ -0,0 +1,3 @@ +# hostname + +{{ #include ../../_generated/hostname-help.md }} diff --git a/docs/src/utils/id.md b/docs/src/utils/id.md new file mode 100644 index 000000000..9b850a470 --- /dev/null +++ b/docs/src/utils/id.md @@ -0,0 +1,3 @@ +# id + +{{ #include ../../_generated/id-help.md }} diff --git a/docs/src/utils/index.md b/docs/src/utils/index.md new file mode 100644 index 000000000..9a0c312f1 --- /dev/null +++ b/docs/src/utils/index.md @@ -0,0 +1,102 @@ +# Utils + +* [arch](./arch.md) +* [base32](./base32.md) +* [base64](./base64.md) +* [basename](./basename.md) +* [basenc](./basenc.md) +* [cat](./cat.md) +* [chcon](./chcon.md) +* [chgrp](./chgrp.md) +* [chmod](./chmod.md) +* [chown](./chown.md) +* [chroot](./chroot.md) +* [cksum](./cksum.md) +* [comm](./comm.md) +* [cp](./cp.md) +* [csplit](./csplit.md) +* [cut](./cut.md) +* [date](./date.md) +* [dd](./dd.md) +* [df](./df.md) +* [dircolors](./dircolors.md) +* [dirname](./dirname.md) +* [du](./du.md) +* [echo](./echo.md) +* [env](./env.md) +* [expand](./expand.md) +* [expr](./expr.md) +* [factor](./factor.md) +* [false](./false.md) +* [fmt](./fmt.md) +* [fold](./fold.md) +* [groups](./groups.md) +* [hashsum](./hashsum.md) +* [head](./head.md) +* [hostid](./hostid.md) +* [hostname](./hostname.md) +* [id](./id.md) +* [install](./install.md) +* [join](./join.md) +* [kill](./kill.md) +* [link](./link.md) +* [ln](./ln.md) +* [logname](./logname.md) +* [ls](./ls.md) +* [mkdir](./mkdir.md) +* [mkfifo](./mkfifo.md) +* [mknod](./mknod.md) +* [mktemp](./mktemp.md) +* [more](./more.md) +* [mv](./mv.md) +* [nice](./nice.md) +* [nl](./nl.md) +* [nohup](./nohup.md) +* [nproc](./nproc.md) +* [numfmt](./numfmt.md) +* [od](./od.md) +* [paste](./paste.md) +* [pathchk](./pathchk.md) +* [pinky](./pinky.md) +* [pr](./pr.md) +* [printenv](./printenv.md) +* [printf](./printf.md) +* [ptx](./ptx.md) +* [pwd](./pwd.md) +* [readlink](./readlink.md) +* [realpath](./realpath.md) +* [relpath](./relpath.md) +* [rm](./rm.md) +* [rmdir](./rmdir.md) +* [runcon](./runcon.md) +* [seq](./seq.md) +* [shred](./shred.md) +* [shuf](./shuf.md) +* [sleep](./sleep.md) +* [sort](./sort.md) +* [split](./split.md) +* [stat](./stat.md) +* [stdbuf](./stdbuf.md) +* [sum](./sum.md) +* [sync](./sync.md) +* [tac](./tac.md) +* [tail](./tail.md) +* [tee](./tee.md) +* [test](./test.md) +* [timeout](./timeout.md) +* [touch](./touch.md) +* [tr](./tr.md) +* [true](./true.md) +* [truncate](./truncate.md) +* [tsort](./tsort.md) +* [tty](./tty.md) +* [uname](./uname.md) +* [unexpand](./unexpand.md) +* [uniq](./uniq.md) +* [unlink](./unlink.md) +* [uptime](./uptime.md) +* [users](./users.md) +* [wc](./wc.md) +* [who](./who.md) +* [whoami](./whoami.md) +* [yes](./yes.md) diff --git a/docs/src/utils/install.md b/docs/src/utils/install.md new file mode 100644 index 000000000..3c91e59f4 --- /dev/null +++ b/docs/src/utils/install.md @@ -0,0 +1,3 @@ +# install + +{{ #include ../../_generated/install-help.md }} diff --git a/docs/src/utils/join.md b/docs/src/utils/join.md new file mode 100644 index 000000000..1f386e271 --- /dev/null +++ b/docs/src/utils/join.md @@ -0,0 +1,3 @@ +# join + +{{ #include ../../_generated/join-help.md }} diff --git a/docs/src/utils/kill.md b/docs/src/utils/kill.md new file mode 100644 index 000000000..8120c21bc --- /dev/null +++ b/docs/src/utils/kill.md @@ -0,0 +1,3 @@ +# kill + +{{ #include ../../_generated/kill-help.md }} diff --git a/docs/src/utils/link.md b/docs/src/utils/link.md new file mode 100644 index 000000000..8a9666eef --- /dev/null +++ b/docs/src/utils/link.md @@ -0,0 +1,3 @@ +# link + +{{ #include ../../_generated/link-help.md }} diff --git a/docs/src/utils/ln.md b/docs/src/utils/ln.md new file mode 100644 index 000000000..b8722a550 --- /dev/null +++ b/docs/src/utils/ln.md @@ -0,0 +1,3 @@ +# ln + +{{ #include ../../_generated/ln-help.md }} diff --git a/docs/src/utils/logname.md b/docs/src/utils/logname.md new file mode 100644 index 000000000..3d9aadb52 --- /dev/null +++ b/docs/src/utils/logname.md @@ -0,0 +1,3 @@ +# logname + +{{ #include ../../_generated/logname-help.md }} diff --git a/docs/src/utils/ls.md b/docs/src/utils/ls.md new file mode 100644 index 000000000..8476a4772 --- /dev/null +++ b/docs/src/utils/ls.md @@ -0,0 +1,3 @@ +# ls + +{{ #include ../../_generated/ls-help.md }} diff --git a/docs/src/utils/mkdir.md b/docs/src/utils/mkdir.md new file mode 100644 index 000000000..896f6e933 --- /dev/null +++ b/docs/src/utils/mkdir.md @@ -0,0 +1,3 @@ +# mkdir + +{{ #include ../../_generated/mkdir-help.md }} diff --git a/docs/src/utils/mkfifo.md b/docs/src/utils/mkfifo.md new file mode 100644 index 000000000..7b7514722 --- /dev/null +++ b/docs/src/utils/mkfifo.md @@ -0,0 +1,3 @@ +# mkfifo + +{{ #include ../../_generated/mkfifo-help.md }} diff --git a/docs/src/utils/mknod.md b/docs/src/utils/mknod.md new file mode 100644 index 000000000..e5c44b883 --- /dev/null +++ b/docs/src/utils/mknod.md @@ -0,0 +1,3 @@ +# mknod + +{{ #include ../../_generated/mknod-help.md }} diff --git a/docs/src/utils/mktemp.md b/docs/src/utils/mktemp.md new file mode 100644 index 000000000..445dc6872 --- /dev/null +++ b/docs/src/utils/mktemp.md @@ -0,0 +1,3 @@ +# mktemp + +{{ #include ../../_generated/mktemp-help.md }} diff --git a/docs/src/utils/more.md b/docs/src/utils/more.md new file mode 100644 index 000000000..209832840 --- /dev/null +++ b/docs/src/utils/more.md @@ -0,0 +1,3 @@ +# more + +{{ #include ../../_generated/more-help.md }} diff --git a/docs/src/utils/mv.md b/docs/src/utils/mv.md new file mode 100644 index 000000000..7e72d9c6d --- /dev/null +++ b/docs/src/utils/mv.md @@ -0,0 +1,3 @@ +# mv + +{{ #include ../../_generated/mv-help.md }} diff --git a/docs/src/utils/nice.md b/docs/src/utils/nice.md new file mode 100644 index 000000000..ab304bff0 --- /dev/null +++ b/docs/src/utils/nice.md @@ -0,0 +1,3 @@ +# nice + +{{ #include ../../_generated/nice-help.md }} diff --git a/docs/src/utils/nl.md b/docs/src/utils/nl.md new file mode 100644 index 000000000..b1f24f064 --- /dev/null +++ b/docs/src/utils/nl.md @@ -0,0 +1,3 @@ +# nl + +{{ #include ../../_generated/nl-help.md }} diff --git a/docs/src/utils/nohup.md b/docs/src/utils/nohup.md new file mode 100644 index 000000000..367254bee --- /dev/null +++ b/docs/src/utils/nohup.md @@ -0,0 +1,3 @@ +# nohup + +{{ #include ../../_generated/nohup-help.md }} diff --git a/docs/src/utils/nproc.md b/docs/src/utils/nproc.md new file mode 100644 index 000000000..b4ef4eaa4 --- /dev/null +++ b/docs/src/utils/nproc.md @@ -0,0 +1,3 @@ +# nproc + +{{ #include ../../_generated/nproc-help.md }} diff --git a/docs/src/utils/numfmt.md b/docs/src/utils/numfmt.md new file mode 100644 index 000000000..f811efbaa --- /dev/null +++ b/docs/src/utils/numfmt.md @@ -0,0 +1,3 @@ +# numfmt + +{{ #include ../../_generated/numfmt-help.md }} diff --git a/docs/src/utils/od.md b/docs/src/utils/od.md new file mode 100644 index 000000000..8b366b8fd --- /dev/null +++ b/docs/src/utils/od.md @@ -0,0 +1,3 @@ +# od + +{{ #include ../../_generated/od-help.md }} diff --git a/docs/src/utils/paste.md b/docs/src/utils/paste.md new file mode 100644 index 000000000..86038f1a8 --- /dev/null +++ b/docs/src/utils/paste.md @@ -0,0 +1,3 @@ +# paste + +{{ #include ../../_generated/paste-help.md }} diff --git a/docs/src/utils/pathchk.md b/docs/src/utils/pathchk.md new file mode 100644 index 000000000..f04139eec --- /dev/null +++ b/docs/src/utils/pathchk.md @@ -0,0 +1,3 @@ +# pathchk + +{{ #include ../../_generated/pathchk-help.md }} diff --git a/docs/src/utils/pinky.md b/docs/src/utils/pinky.md new file mode 100644 index 000000000..1efe4ff45 --- /dev/null +++ b/docs/src/utils/pinky.md @@ -0,0 +1,3 @@ +# pinky + +{{ #include ../../_generated/pinky-help.md }} diff --git a/docs/src/utils/pr.md b/docs/src/utils/pr.md new file mode 100644 index 000000000..82b9c938d --- /dev/null +++ b/docs/src/utils/pr.md @@ -0,0 +1,3 @@ +# pr + +{{ #include ../../_generated/pr-help.md }} diff --git a/docs/src/utils/printenv.md b/docs/src/utils/printenv.md new file mode 100644 index 000000000..5543f1e13 --- /dev/null +++ b/docs/src/utils/printenv.md @@ -0,0 +1,3 @@ +# printenv + +{{ #include ../../_generated/printenv-help.md }} diff --git a/docs/src/utils/printf.md b/docs/src/utils/printf.md new file mode 100644 index 000000000..e11fff3df --- /dev/null +++ b/docs/src/utils/printf.md @@ -0,0 +1,3 @@ +# printf + +{{ #include ../../_generated/printf-help.md }} diff --git a/docs/src/utils/ptx.md b/docs/src/utils/ptx.md new file mode 100644 index 000000000..e755a058d --- /dev/null +++ b/docs/src/utils/ptx.md @@ -0,0 +1,3 @@ +# ptx + +{{ #include ../../_generated/ptx-help.md }} diff --git a/docs/src/utils/pwd.md b/docs/src/utils/pwd.md new file mode 100644 index 000000000..b3122b336 --- /dev/null +++ b/docs/src/utils/pwd.md @@ -0,0 +1,3 @@ +# pwd + +{{ #include ../../_generated/pwd-help.md }} diff --git a/docs/src/utils/readlink.md b/docs/src/utils/readlink.md new file mode 100644 index 000000000..56db08517 --- /dev/null +++ b/docs/src/utils/readlink.md @@ -0,0 +1,3 @@ +# readlink + +{{ #include ../../_generated/readlink-help.md }} diff --git a/docs/src/utils/realpath.md b/docs/src/utils/realpath.md new file mode 100644 index 000000000..22bc83475 --- /dev/null +++ b/docs/src/utils/realpath.md @@ -0,0 +1,3 @@ +# realpath + +{{ #include ../../_generated/realpath-help.md }} diff --git a/docs/src/utils/relpath.md b/docs/src/utils/relpath.md new file mode 100644 index 000000000..51acd2c87 --- /dev/null +++ b/docs/src/utils/relpath.md @@ -0,0 +1,3 @@ +# relpath + +{{ #include ../../_generated/relpath-help.md }} diff --git a/docs/src/utils/rm.md b/docs/src/utils/rm.md new file mode 100644 index 000000000..dfb24f242 --- /dev/null +++ b/docs/src/utils/rm.md @@ -0,0 +1,3 @@ +# rm + +{{ #include ../../_generated/rm-help.md }} diff --git a/docs/src/utils/rmdir.md b/docs/src/utils/rmdir.md new file mode 100644 index 000000000..1c8d5f205 --- /dev/null +++ b/docs/src/utils/rmdir.md @@ -0,0 +1,3 @@ +# rmdir + +{{ #include ../../_generated/rmdir-help.md }} diff --git a/docs/src/utils/runcon.md b/docs/src/utils/runcon.md new file mode 100644 index 000000000..011361492 --- /dev/null +++ b/docs/src/utils/runcon.md @@ -0,0 +1,3 @@ +# runcon + +{{ #include ../../_generated/runcon-help.md }} diff --git a/docs/src/utils/seq.md b/docs/src/utils/seq.md new file mode 100644 index 000000000..23fdf04cf --- /dev/null +++ b/docs/src/utils/seq.md @@ -0,0 +1,3 @@ +# seq + +{{ #include ../../_generated/seq-help.md }} diff --git a/docs/src/utils/shred.md b/docs/src/utils/shred.md new file mode 100644 index 000000000..4eae89785 --- /dev/null +++ b/docs/src/utils/shred.md @@ -0,0 +1,3 @@ +# shred + +{{ #include ../../_generated/shred-help.md }} diff --git a/docs/src/utils/shuf.md b/docs/src/utils/shuf.md new file mode 100644 index 000000000..1d898ef65 --- /dev/null +++ b/docs/src/utils/shuf.md @@ -0,0 +1,3 @@ +# shuf + +{{ #include ../../_generated/shuf-help.md }} diff --git a/docs/src/utils/sleep.md b/docs/src/utils/sleep.md new file mode 100644 index 000000000..c115868b3 --- /dev/null +++ b/docs/src/utils/sleep.md @@ -0,0 +1,3 @@ +# sleep + +{{ #include ../../_generated/sleep-help.md }} diff --git a/docs/src/utils/sort.md b/docs/src/utils/sort.md new file mode 100644 index 000000000..7b66f920f --- /dev/null +++ b/docs/src/utils/sort.md @@ -0,0 +1,3 @@ +# sort + +{{ #include ../../_generated/sort-help.md }} diff --git a/docs/src/utils/split.md b/docs/src/utils/split.md new file mode 100644 index 000000000..0aa795247 --- /dev/null +++ b/docs/src/utils/split.md @@ -0,0 +1,3 @@ +# split + +{{ #include ../../_generated/split-help.md }} diff --git a/docs/src/utils/stat.md b/docs/src/utils/stat.md new file mode 100644 index 000000000..deb2c57d2 --- /dev/null +++ b/docs/src/utils/stat.md @@ -0,0 +1,3 @@ +# stat + +{{ #include ../../_generated/stat-help.md }} diff --git a/docs/src/utils/stdbuf.md b/docs/src/utils/stdbuf.md new file mode 100644 index 000000000..d13c3ece0 --- /dev/null +++ b/docs/src/utils/stdbuf.md @@ -0,0 +1,3 @@ +# stdbuf + +{{ #include ../../_generated/stdbuf-help.md }} diff --git a/docs/src/utils/sum.md b/docs/src/utils/sum.md new file mode 100644 index 000000000..2475c2d65 --- /dev/null +++ b/docs/src/utils/sum.md @@ -0,0 +1,3 @@ +# sum + +{{ #include ../../_generated/sum-help.md }} diff --git a/docs/src/utils/sync.md b/docs/src/utils/sync.md new file mode 100644 index 000000000..5a8d393bd --- /dev/null +++ b/docs/src/utils/sync.md @@ -0,0 +1,3 @@ +# sync + +{{ #include ../../_generated/sync-help.md }} diff --git a/docs/src/utils/tac.md b/docs/src/utils/tac.md new file mode 100644 index 000000000..914f2d372 --- /dev/null +++ b/docs/src/utils/tac.md @@ -0,0 +1,3 @@ +# tac + +{{ #include ../../_generated/tac-help.md }} diff --git a/docs/src/utils/tail.md b/docs/src/utils/tail.md new file mode 100644 index 000000000..35863797e --- /dev/null +++ b/docs/src/utils/tail.md @@ -0,0 +1,3 @@ +# tail + +{{ #include ../../_generated/tail-help.md }} diff --git a/docs/src/utils/tee.md b/docs/src/utils/tee.md new file mode 100644 index 000000000..b845a75e5 --- /dev/null +++ b/docs/src/utils/tee.md @@ -0,0 +1,3 @@ +# tee + +{{ #include ../../_generated/tee-help.md }} diff --git a/docs/src/utils/test.md b/docs/src/utils/test.md new file mode 100644 index 000000000..e02ba1157 --- /dev/null +++ b/docs/src/utils/test.md @@ -0,0 +1,3 @@ +# test + +{{ #include ../../_generated/test-help.md }} diff --git a/docs/src/utils/timeout.md b/docs/src/utils/timeout.md new file mode 100644 index 000000000..d870fa1af --- /dev/null +++ b/docs/src/utils/timeout.md @@ -0,0 +1,3 @@ +# timeout + +{{ #include ../../_generated/timeout-help.md }} diff --git a/docs/src/utils/touch.md b/docs/src/utils/touch.md new file mode 100644 index 000000000..d68b4f6e9 --- /dev/null +++ b/docs/src/utils/touch.md @@ -0,0 +1,3 @@ +# touch + +{{ #include ../../_generated/touch-help.md }} diff --git a/docs/src/utils/tr.md b/docs/src/utils/tr.md new file mode 100644 index 000000000..39fbfcf6c --- /dev/null +++ b/docs/src/utils/tr.md @@ -0,0 +1,3 @@ +# tr + +{{ #include ../../_generated/tr-help.md }} diff --git a/docs/src/utils/true.md b/docs/src/utils/true.md new file mode 100644 index 000000000..c3448c906 --- /dev/null +++ b/docs/src/utils/true.md @@ -0,0 +1,3 @@ +# true + +{{ #include ../../_generated/true-help.md }} diff --git a/docs/src/utils/truncate.md b/docs/src/utils/truncate.md new file mode 100644 index 000000000..402d56d68 --- /dev/null +++ b/docs/src/utils/truncate.md @@ -0,0 +1,3 @@ +# truncate + +{{ #include ../../_generated/truncate-help.md }} diff --git a/docs/src/utils/tsort.md b/docs/src/utils/tsort.md new file mode 100644 index 000000000..a418fa4e7 --- /dev/null +++ b/docs/src/utils/tsort.md @@ -0,0 +1,3 @@ +# tsort + +{{ #include ../../_generated/tsort-help.md }} diff --git a/docs/src/utils/tty.md b/docs/src/utils/tty.md new file mode 100644 index 000000000..2c1da1c47 --- /dev/null +++ b/docs/src/utils/tty.md @@ -0,0 +1,3 @@ +# tty + +{{ #include ../../_generated/tty-help.md }} diff --git a/docs/src/utils/uname.md b/docs/src/utils/uname.md new file mode 100644 index 000000000..1436d5599 --- /dev/null +++ b/docs/src/utils/uname.md @@ -0,0 +1,3 @@ +# uname + +{{ #include ../../_generated/uname-help.md }} diff --git a/docs/src/utils/unexpand.md b/docs/src/utils/unexpand.md new file mode 100644 index 000000000..05a2b33b8 --- /dev/null +++ b/docs/src/utils/unexpand.md @@ -0,0 +1,3 @@ +# unexpand + +{{ #include ../../_generated/unexpand-help.md }} diff --git a/docs/src/utils/uniq.md b/docs/src/utils/uniq.md new file mode 100644 index 000000000..f9f561e32 --- /dev/null +++ b/docs/src/utils/uniq.md @@ -0,0 +1,3 @@ +# uniq + +{{ #include ../../_generated/uniq-help.md }} diff --git a/docs/src/utils/unlink.md b/docs/src/utils/unlink.md new file mode 100644 index 000000000..5888bb2a8 --- /dev/null +++ b/docs/src/utils/unlink.md @@ -0,0 +1,3 @@ +# unlink + +{{ #include ../../_generated/unlink-help.md }} diff --git a/docs/src/utils/uptime.md b/docs/src/utils/uptime.md new file mode 100644 index 000000000..336a5edd9 --- /dev/null +++ b/docs/src/utils/uptime.md @@ -0,0 +1,3 @@ +# uptime + +{{ #include ../../_generated/uptime-help.md }} diff --git a/docs/src/utils/users.md b/docs/src/utils/users.md new file mode 100644 index 000000000..de20c96ed --- /dev/null +++ b/docs/src/utils/users.md @@ -0,0 +1,3 @@ +# users + +{{ #include ../../_generated/users-help.md }} diff --git a/docs/src/utils/wc.md b/docs/src/utils/wc.md new file mode 100644 index 000000000..c5fffdeab --- /dev/null +++ b/docs/src/utils/wc.md @@ -0,0 +1,3 @@ +# wc + +{{ #include ../../_generated/wc-help.md }} diff --git a/docs/src/utils/who.md b/docs/src/utils/who.md new file mode 100644 index 000000000..9cd7f5ba7 --- /dev/null +++ b/docs/src/utils/who.md @@ -0,0 +1,3 @@ +# who + +{{ #include ../../_generated/who-help.md }} diff --git a/docs/src/utils/whoami.md b/docs/src/utils/whoami.md new file mode 100644 index 000000000..4e896a30a --- /dev/null +++ b/docs/src/utils/whoami.md @@ -0,0 +1,3 @@ +# whoami + +{{ #include ../../_generated/whoami-help.md }} diff --git a/docs/src/utils/yes.md b/docs/src/utils/yes.md new file mode 100644 index 000000000..fbf18307a --- /dev/null +++ b/docs/src/utils/yes.md @@ -0,0 +1,3 @@ +# yes + +{{ #include ../../_generated/yes-help.md }} diff --git a/docs/uutils.rst b/docs/uutils.rst deleted file mode 100644 index e3b8c6a1a..000000000 --- a/docs/uutils.rst +++ /dev/null @@ -1,24 +0,0 @@ -.. run core utilities - -====== -uutils -====== - -.. FIXME: this needs to be autogenerated somehow - --------- -Synopsis --------- - -``uutils`` [OPTION]... [PROGRAM] [OPTION]... [ARGUMENTS]... - ------------ -Description ------------ - -``uutils`` is a program that contains other coreutils commands, somewhat -similar to Busybox. - ---help, -h print a help menu for PROGRAM displaying accepted options and - arguments; if PROGRAM was not given, do the same but for this - program diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs index 65da4c7cc..ce51e8833 100644 --- a/src/bin/uudoc.rs +++ b/src/bin/uudoc.rs @@ -6,109 +6,64 @@ // file that was distributed with this source code. use clap::App; -use clap::Arg; -use clap::Shell; -use std::cmp; use std::collections::hash_map::HashMap; -use std::ffi::OsStr; use std::ffi::OsString; -use std::io::{self, Write}; -use std::path::{Path, PathBuf}; -use std::process; -use uucore::display::Quotable; - -const VERSION: &str = env!("CARGO_PKG_VERSION"); +use std::fs::File; +use std::io::Write; include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); -fn usage(utils: &UtilityMap, name: &str) { - println!("{} {}\n", name, VERSION); - println!("Generate markdown documentation for uutils"); - println!("Usage: {} [util]\n", name); - println!("Currently defined functions:\n"); - #[allow(clippy::map_clone)] - let mut utils: Vec<&str> = utils.keys().map(|&s| s).collect(); - utils.sort_unstable(); - let display_list = utils.join(", "); - let width = cmp::min(textwrap::termwidth(), 100) - 4 * 2; // (opinion/heuristic) max 100 chars wide with 4 character side indentions - println!( - "{}", - textwrap::indent(&textwrap::fill(&display_list, width), " ") - ); -} - -fn binary_path(args: &mut impl Iterator) -> PathBuf { - match args.next() { - Some(ref s) if !s.is_empty() => PathBuf::from(s), - _ => std::env::current_exe().unwrap(), - } -} - -fn name(binary_path: &Path) -> &str { - binary_path.file_stem().unwrap().to_str().unwrap() -} - fn main() { uucore::panic::mute_sigpipe_panic(); - let utils = util_map(); - let mut args = uucore::args_os(); + let utils = util_map::>>(); - let binary = binary_path(&mut args); - let binary_as_util = name(&binary); - - // binary name equals util name? - if let Some(&(uumain, _)) = utils.get(binary_as_util) { - process::exit(uumain((vec![binary.into()].into_iter()).chain(args))); - } - - // binary name equals prefixed util name? - // * prefix/stem may be any string ending in a non-alphanumeric character - let util_name = if let Some(util) = utils.keys().find(|util| { - binary_as_util.ends_with(*util) - && !(&binary_as_util[..binary_as_util.len() - (*util).len()]) - .ends_with(char::is_alphanumeric) - }) { - // prefixed util => replace 0th (aka, executable name) argument - Some(OsString::from(*util)) - } else { - // unmatched binary name => regard as multi-binary container and advance argument list - uucore::set_utility_is_second_arg(); - args.next() - }; - - // 0th argument equals util name? - if let Some(util_os) = util_name { - fn not_found(util: &OsStr) -> ! { - println!("{}: function/utility not found", util.maybe_quote()); - process::exit(1); + for (name, (_, app)) in utils { + let p = format!("docs/_generated/{}-help.md", name); + if let Ok(f) = File::create(&p) { + write_markdown(f, &mut app()); + println!("Wrote to '{}'", p); } - - let util = match util_os.to_str() { - Some(util) => util, - None => not_found(&util_os), - }; - - match utils.get(util) { - Some(&(uumain, app)) => { - print_markdown(app); - } - None => { - if util == "--help" || util == "-h" { - usage(&utils, binary_as_util); - process::exit(0); - } else { - not_found(&util_os); - } - } - } - } else { - // no arguments provided - usage(&utils, binary_as_util); - process::exit(0); } } -fn print_markdown(app: &App) { - for arg in app.get_arguments() {} +fn write_markdown(mut w: impl Write, app: &mut App) { + write_summary(&mut w, app); + write_options(&mut w, app); +} + +fn write_summary(w: &mut impl Write, app: &App) { + if let Some(about) = app.get_long_about().or_else(|| app.get_about()) { + let _ = writeln!(w, "

Summary

"); + let _ = writeln!(w, "{}", about); + } +} + +fn write_options(w: &mut impl Write, app: &App) { + let _ = writeln!(w, "

Options

"); + let _ = write!(w, "
"); + for arg in app.get_arguments() { + let _ = write!(w, "
"); + let mut first = true; + for l in arg.get_long_and_visible_aliases().unwrap_or_default() { + if !first { + let _ = write!(w, ", "); + } else { + first = false; + } + let _ = write!(w, "--{}", l); + } + for l in arg.get_short_and_visible_aliases().unwrap_or_default() { + if !first { + let _ = write!(w, ", "); + } else { + first = false; + } + let _ = write!(w, "-{}", l); + } + let _ = writeln!(w, "
"); + + let _ = writeln!(w, "
{}
", arg.get_help().unwrap_or_default()); + } + let _ = writeln!(w, "
"); }