diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..c999c41 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,758 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", + "terminal_size 0.3.0", +] + +[[package]] +name = "clap_complete" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c" +dependencies = [ + "clap", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "clap_mangen" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1dd95b5ebb5c1c54581dd6346f3ed6a79a3eef95dd372fc2ac13d535535300e" +dependencies = [ + "clap", + "roff", +] + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hostname" +version = "0.0.1" +dependencies = [ + "clap", + "clap_complete", + "clap_mangen", + "libc", + "phf", + "phf_codegen", + "pretty_assertions", + "procfs", + "rand", + "regex", + "rlimit", + "tempfile", + "textwrap", + "uu_hostname", + "uucore", + "xattr", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "os_display" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6229bad892b46b0dcfaaeb18ad0d2e56400f5aaea05b768bde96e73676cf75" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "procfs" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731e0d9356b0c25f16f33b5be79b1c57b562f141ebfcdb0ad8ac2c13a24293b4" +dependencies = [ + "bitflags 2.5.0", + "hex", + "lazy_static", + "procfs-core", + "rustix 0.38.32", +] + +[[package]] +name = "procfs-core" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29" +dependencies = [ + "bitflags 2.5.0", + "hex", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "rlimit" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3560f70f30a0f16d11d01ed078a07740fe6b489667abc7c7b029155d9f21c3d8" +dependencies = [ + "libc", +] + +[[package]] +name = "roff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" + +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys 0.4.13", + "windows-sys 0.52.0", +] + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix 0.38.32", + "windows-sys 0.52.0", +] + +[[package]] +name = "terminal_size" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +dependencies = [ + "rustix 0.37.27", + "windows-sys 0.48.0", +] + +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix 0.38.32", + "windows-sys 0.48.0", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "terminal_size 0.2.6", + "unicode-linebreak", + "unicode-width", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uu_hostname" +version = "0.0.1" +dependencies = [ + "clap", + "uucore", +] + +[[package]] +name = "uucore" +version = "0.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5de2eba1364f6274f35f121eb8671b98ac5fa8fe1271694721e17034e85e8bc" +dependencies = [ + "clap", + "glob", + "libc", + "nix", + "once_cell", + "os_display", + "uucore_procs", + "wild", +] + +[[package]] +name = "uucore_procs" +version = "0.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7f51594832e53b11811446b1cd3567722e2906a589a5b19622c5c4720977309" +dependencies = [ + "proc-macro2", + "quote", + "uuhelp_parser", +] + +[[package]] +name = "uuhelp_parser" +version = "0.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac7a6832a5add86204d5a8d0ef41c5a11e3ddf61c0f1a508f69e7e3e1bf04e3f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wild" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3131afc8c575281e1e80f36ed6a092aa502c08b18ed7524e86fbbb12bb410e1" +dependencies = [ + "glob", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys 0.4.13", + "rustix 0.38.32", +] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7ad7444 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,104 @@ +# hostname (uutils) +# * see the repository LICENSE, README, and CONTRIBUTING files for more information + +# spell-checker:ignore (libs) bigdecimal datetime fundu gethostid kqueue libselinux mangen memmap procfs uuhelp + +[package] +name = "hostname" +version = "0.0.1" +authors = ["uutils developers"] +license = "MIT" +description = "hostname ~ implemented as universal (cross-platform) utils, written in Rust" +default-run = "hostname" + +homepage = "https://github.com/uutils/hostname" +repository = "https://github.com/uutils/hostname" +readme = "README.md" +keywords = ["hostname", "uutils", "cross-platform", "cli", "utility"] +categories = ["command-line-utilities"] +rust-version = "1.70.0" +edition = "2021" + +build = "build.rs" + +[features] +default = ["feat_common_core"] + +feat_common_core = [ + "hostname", +] + +[workspace.dependencies] +uucore = "0.0.24" +clap = { version = "4.4", features = ["wrap_help", "cargo"] } +clap_complete = "4.4" +clap_mangen = "0.2" +regex = "1.10.3" +sysinfo = "0.30" +libc = "0.2.152" +phf = "0.11.2" +phf_codegen = "0.11.2" +textwrap = { version = "0.16.1", features = ["terminal_size"] } +xattr = "1.3.1" +tempfile = "3.9.0" +rand = { version = "0.8", features = ["small_rng"] } +utmpx = "0.1" + +[dependencies] +clap = { workspace = true } +clap_complete = { workspace = true } +clap_mangen = { workspace = true } +uucore = { workspace = true } +phf = { workspace = true } +textwrap = { workspace = true } + + +# +hostname = { optional = true, version = "0.0.1", package = "uu_hostname", path = "src/uu/hostname" } + +[dev-dependencies] +pretty_assertions = "1" +regex = { workspace = true } +tempfile = { workspace = true } +libc = { workspace = true } +rand = { workspace = true } +uucore = { workspace = true, features = ["entries", "process", "signals"] } + +[target.'cfg(unix)'.dev-dependencies] +xattr = { workspace = true } + +[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies] +procfs = { version = "0.16", default-features = false } +rlimit = "0.10.1" + +[build-dependencies] +phf_codegen = { workspace = true } + + +[[bin]] +name = "hostname" +path = "src/bin/hostname.rs" + +[[bin]] +name = "uudoc" +path = "src/bin/uudoc.rs" +required-features = ["uudoc"] + +# The default release profile. It contains all optimizations, without +# sacrificing debug info. With this profile (like in the standard +# release profile), the debug info and the stack traces will still be available. +[profile.release] +lto = true + +# A release-like profile that is tuned to be fast, even when being fast +# compromises on binary size. This includes aborting on panic. +[profile.release-fast] +inherits = "release" +panic = "abort" + +# A release-like profile that is as small as possible. +[profile.release-small] +inherits = "release" +opt-level = "z" +panic = "abort" +strip = true diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..ccd7d3b --- /dev/null +++ b/build.rs @@ -0,0 +1,101 @@ +// This file is part of the uutils login package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +// spell-checker:ignore (vars) krate + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::Path; + +pub fn main() { + if let Ok(profile) = env::var("PROFILE") { + println!("cargo:rustc-cfg=build={profile:?}"); + } + + const ENV_FEATURE_PREFIX: &str = "CARGO_FEATURE_"; + const FEATURE_PREFIX: &str = "feat_"; + const OVERRIDE_PREFIX: &str = "uu_"; + + let out_dir = env::var("OUT_DIR").unwrap(); + + let mut crates = Vec::new(); + for (key, val) in env::vars() { + if val == "1" && key.starts_with(ENV_FEATURE_PREFIX) { + let krate = key[ENV_FEATURE_PREFIX.len()..].to_lowercase(); + // Allow this as we have a bunch of info in the comments + #[allow(clippy::match_same_arms)] + match krate.as_ref() { + "default" | "macos" | "unix" | "windows" | "selinux" | "zip" => continue, // common/standard feature names + "nightly" | "test_unimplemented" => continue, // crate-local custom features + "uudoc" => continue, // is not a utility + "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); + } + } + crates.sort(); + + let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap(); + + mf.write_all( + "type UtilityMap = phf::OrderedMap<&'static str, (fn(T) -> i32, fn() -> Command)>;\n\ + \n\ + #[allow(clippy::too_many_lines)] + fn util_map() -> UtilityMap {\n" + .as_bytes(), + ) + .unwrap(); + + let mut phf_map = phf_codegen::OrderedMap::<&str>::new(); + for krate in &crates { + let map_value = format!("({krate}::uumain, {krate}::uu_app)"); + match krate.as_ref() { + // 'test' is named uu_test to avoid collision with rust core crate 'test'. + // It can also be invoked by name '[' for the '[ expr ] syntax'. + "uu_test" => { + phf_map.entry("test", &map_value); + phf_map.entry("[", &map_value); + } + k if k.starts_with(OVERRIDE_PREFIX) => { + phf_map.entry(&k[OVERRIDE_PREFIX.len()..], &map_value); + } + "false" | "true" => { + phf_map.entry(krate, &format!("(r#{krate}::uumain, r#{krate}::uu_app)")); + } + "hashsum" => { + phf_map.entry(krate, &format!("({krate}::uumain, {krate}::uu_app_custom)")); + + let map_value = format!("({krate}::uumain, {krate}::uu_app_common)"); + let map_value_bits = format!("({krate}::uumain, {krate}::uu_app_bits)"); + let map_value_b3sum = format!("({krate}::uumain, {krate}::uu_app_b3sum)"); + phf_map.entry("md5sum", &map_value); + phf_map.entry("sha1sum", &map_value); + phf_map.entry("sha224sum", &map_value); + phf_map.entry("sha256sum", &map_value); + phf_map.entry("sha384sum", &map_value); + phf_map.entry("sha512sum", &map_value); + phf_map.entry("sha3sum", &map_value_bits); + phf_map.entry("sha3-224sum", &map_value); + phf_map.entry("sha3-256sum", &map_value); + phf_map.entry("sha3-384sum", &map_value); + phf_map.entry("sha3-512sum", &map_value); + phf_map.entry("shake128sum", &map_value_bits); + phf_map.entry("shake256sum", &map_value_bits); + phf_map.entry("b2sum", &map_value); + phf_map.entry("b3sum", &map_value_b3sum); + } + _ => { + phf_map.entry(krate, &map_value); + } + } + } + write!(mf, "{}", phf_map.build()).unwrap(); + mf.write_all(b"\n}\n").unwrap(); + + mf.flush().unwrap(); +} diff --git a/src/bin/hostname.rs b/src/bin/hostname.rs new file mode 100644 index 0000000..3dbe51b --- /dev/null +++ b/src/bin/hostname.rs @@ -0,0 +1,224 @@ +// This file is part of the uutils hostname package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +// spell-checker:ignore manpages mangen + +use clap::{Arg, Command}; +use clap_complete::Shell; +use std::cmp; +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"); + +include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); + +fn usage(utils: &UtilityMap, name: &str) { + println!("{name} {VERSION} (multi-call binary)\n"); + println!("Usage: {name} [function [arguments...]]\n"); + 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) -> Option<&str> { + binary_path.file_stem()?.to_str() +} + +#[allow(clippy::cognitive_complexity)] +fn main() { + uucore::panic::mute_sigpipe_panic(); + + let utils = util_map(); + let mut args = uucore::args_os(); + + let binary = binary_path(&mut args); + let binary_as_util = name(&binary).unwrap_or_else(|| { + usage(&utils, ""); + process::exit(0); + }); + + // 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); + } + + let util = match util_os.to_str() { + Some(util) => util, + None => not_found(&util_os), + }; + + if util == "completion" { + gen_completions(args, &utils); + } + + if util == "manpage" { + gen_manpage(args, &utils); + } + + match utils.get(util) { + Some(&(uumain, _)) => { + process::exit(uumain((vec![util_os].into_iter()).chain(args))); + } + None => { + if util == "--help" || util == "-h" { + // see if they want help on a specific util + if let Some(util_os) = args.next() { + let util = match util_os.to_str() { + Some(util) => util, + None => not_found(&util_os), + }; + + match utils.get(util) { + Some(&(uumain, _)) => { + let code = uumain( + (vec![util_os, OsString::from("--help")].into_iter()) + .chain(args), + ); + io::stdout().flush().expect("could not flush stdout"); + process::exit(code); + } + None => not_found(&util_os), + } + } + 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); + } +} + +/// Prints completions for the utility in the first parameter for the shell in the second parameter to stdout +fn gen_completions( + args: impl Iterator, + util_map: &UtilityMap, +) -> ! { + let all_utilities: Vec<_> = std::iter::once("hostname") + .chain(util_map.keys().copied()) + .collect(); + + let matches = Command::new("completion") + .about("Prints completions to stdout") + .arg( + Arg::new("utility") + .value_parser(clap::builder::PossibleValuesParser::new(all_utilities)) + .required(true), + ) + .arg( + Arg::new("shell") + .value_parser(clap::builder::EnumValueParser::::new()) + .required(true), + ) + .get_matches_from(std::iter::once(OsString::from("completion")).chain(args)); + + let utility = matches.get_one::("utility").unwrap(); + let shell = *matches.get_one::("shell").unwrap(); + + let mut command = if utility == "hostname" { + gen_hostname_app(util_map) + } else { + util_map.get(utility).unwrap().1() + }; + let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility; + + clap_complete::generate(shell, &mut command, bin_name, &mut io::stdout()); + io::stdout().flush().unwrap(); + process::exit(0); +} + +/// Generate the manpage for the utility in the first parameter +fn gen_manpage( + args: impl Iterator, + util_map: &UtilityMap, +) -> ! { + let all_utilities: Vec<_> = std::iter::once("hostname") + .chain(util_map.keys().copied()) + .collect(); + + let matches = Command::new("manpage") + .about("Prints manpage to stdout") + .arg( + Arg::new("utility") + .value_parser(clap::builder::PossibleValuesParser::new(all_utilities)) + .required(true), + ) + .get_matches_from(std::iter::once(OsString::from("manpage")).chain(args)); + + let utility = matches.get_one::("utility").unwrap(); + + let command = if utility == "hostname" { + gen_hostname_app(util_map) + } else { + util_map.get(utility).unwrap().1() + }; + + let man = clap_mangen::Man::new(command); + man.render(&mut io::stdout()) + .expect("Man page generation failed"); + io::stdout().flush().unwrap(); + process::exit(0); +} + +fn gen_hostname_app(util_map: &UtilityMap) -> Command { + let mut command = Command::new("hostname"); + for (name, (_, sub_app)) in util_map { + // Recreate a small subcommand with only the relevant info + // (name & short description) + let about = sub_app() + .get_about() + .expect("Could not get the 'about'") + .to_string(); + let sub_app = Command::new(name).about(about); + command = command.subcommand(sub_app); + } + command +} diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs new file mode 100644 index 0000000..8ba1b4a --- /dev/null +++ b/src/bin/uudoc.rs @@ -0,0 +1,361 @@ +// This file is part of the uutils hostname package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. +// spell-checker:ignore tldr uuhelp + +use clap::Command; +use std::collections::HashMap; +use std::ffi::OsString; +use std::fs::File; +use std::io::{self, Read, Seek, Write}; +use zip::ZipArchive; + +include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); + +fn main() -> io::Result<()> { + let mut tldr_zip = File::open("docs/tldr.zip") + .ok() + .and_then(|f| ZipArchive::new(f).ok()); + + if tldr_zip.is_none() { + println!("Warning: No tldr archive found, so the documentation will not include examples."); + println!("To include examples in the documentation, download the tldr archive and put it in the docs/ folder."); + println!(); + println!(" curl https://tldr.sh/assets/tldr.zip -o docs/tldr.zip"); + println!(); + } + + let utils = util_map::>>(); + match std::fs::create_dir("docs/src/utils/") { + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => Ok(()), + x => x, + }?; + + println!("Writing initial info to SUMMARY.md"); + let mut summary = File::create("docs/src/SUMMARY.md")?; + + let _ = write!( + summary, + "# Summary\n\ + \n\ + [Introduction](index.md)\n\ + * [Installation](installation.md)\n\ + * [Build from source](build.md)\n\ + * [Platform support](platforms.md)\n\ + * [Contributing](contributing.md)\n\ + * [GNU test coverage](test_coverage.md)\n\ + * [Extensions](extensions.md)\n\ + \n\ + # Reference\n\ + * [Multi-call binary](multicall.md)\n", + ); + + println!("Gathering utils per platform"); + let utils_per_platform = { + let mut map = HashMap::new(); + for platform in ["unix", "macos", "windows", "unix_android"] { + let platform_utils: Vec = String::from_utf8( + std::process::Command::new("./util/show-utils.sh") + .arg(format!("--features=feat_os_{}", platform)) + .output()? + .stdout, + ) + .unwrap() + .trim() + .split(' ') + .map(ToString::to_string) + .collect(); + map.insert(platform, platform_utils); + } + + // Linux is a special case because it can support selinux + let platform_utils: Vec = String::from_utf8( + std::process::Command::new("./util/show-utils.sh") + .arg("--features=feat_os_unix feat_selinux") + .output()? + .stdout, + ) + .unwrap() + .trim() + .split(' ') + .map(ToString::to_string) + .collect(); + map.insert("linux", platform_utils); + + map + }; + + let mut utils = utils.entries().collect::>(); + utils.sort(); + + println!("Writing util per platform table"); + { + let mut platform_table_file = File::create("docs/src/platform_table.md").unwrap(); + + // sum, cksum, b2sum, etc. are all available on all platforms, but not in the data structure + // otherwise, we check the map for the util name. + let check_supported = |name: &str, platform: &str| { + if name.ends_with("sum") || utils_per_platform[platform].iter().any(|u| u == name) { + "✓" + } else { + " " + } + }; + writeln!( + platform_table_file, + "| util | Linux | macOS | Windows | FreeBSD | Android |\n\ + | ---------------- | ----- | ----- | ------- | ------- | ------- |" + )?; + for (&name, _) in &utils { + if name == "[" { + continue; + } + // The alignment is not necessary, but makes the output a bit more + // pretty when viewed as plain markdown. + writeln!( + platform_table_file, + "| {:<16} | {:<5} | {:<5} | {:<7} | {:<7} | {:<7} |", + format!("**{name}**"), + check_supported(name, "linux"), + check_supported(name, "macos"), + check_supported(name, "windows"), + check_supported(name, "unix"), + check_supported(name, "unix_android"), + )?; + } + } + + println!("Writing to utils"); + for (&name, (_, command)) in utils { + if name == "[" { + continue; + } + let p = format!("docs/src/utils/{}.md", name); + + let markdown = File::open(format!("src/uu/{name}/{name}.md")) + .and_then(|mut f: File| { + let mut s = String::new(); + f.read_to_string(&mut s)?; + Ok(s) + }) + .ok(); + + if let Ok(f) = File::create(&p) { + MDWriter { + w: Box::new(f), + command: command(), + name, + tldr_zip: &mut tldr_zip, + utils_per_platform: &utils_per_platform, + markdown, + } + .markdown()?; + println!("Wrote to '{}'", p); + } else { + println!("Error writing to {}", p); + } + writeln!(summary, "* [{0}](utils/{0}.md)", name)?; + } + Ok(()) +} + +struct MDWriter<'a, 'b> { + w: Box, + command: Command, + name: &'a str, + tldr_zip: &'b mut Option>, + utils_per_platform: &'b HashMap<&'b str, Vec>, + markdown: Option, +} + +impl<'a, 'b> MDWriter<'a, 'b> { + fn markdown(&mut self) -> io::Result<()> { + write!(self.w, "# {}\n\n", self.name)?; + self.additional()?; + self.usage()?; + self.about()?; + self.options()?; + self.after_help()?; + self.examples() + } + + fn additional(&mut self) -> io::Result<()> { + writeln!(self.w, "
")?; + self.platforms()?; + self.version()?; + writeln!(self.w, "
") + } + + fn platforms(&mut self) -> io::Result<()> { + writeln!(self.w, "
")?; + for (feature, icon) in [ + ("linux", "linux"), + // freebsd is disabled for now because mdbook does not use font-awesome 5 yet. + // ("unix", "freebsd"), + ("macos", "apple"), + ("windows", "windows"), + ] { + if self.name.contains("sum") + || self.utils_per_platform[feature] + .iter() + .any(|u| u == self.name) + { + writeln!(self.w, "", icon)?; + } + } + writeln!(self.w, "
")?; + + Ok(()) + } + + fn version(&mut self) -> io::Result<()> { + writeln!( + self.w, + "
v{}
", + self.command.render_version().split_once(' ').unwrap().1 + ) + } + + fn usage(&mut self) -> io::Result<()> { + if let Some(markdown) = &self.markdown { + let usage = uuhelp_parser::parse_usage(markdown); + let usage = usage.replace("{}", self.name); + + writeln!(self.w, "\n```")?; + writeln!(self.w, "{}", usage)?; + writeln!(self.w, "```") + } else { + Ok(()) + } + } + + fn about(&mut self) -> io::Result<()> { + if let Some(markdown) = &self.markdown { + writeln!(self.w, "{}", uuhelp_parser::parse_about(markdown)) + } else { + Ok(()) + } + } + + fn after_help(&mut self) -> io::Result<()> { + if let Some(markdown) = &self.markdown { + if let Some(after_help) = uuhelp_parser::parse_section("after help", markdown) { + return writeln!(self.w, "\n\n{after_help}"); + } + } + + Ok(()) + } + + fn examples(&mut self) -> io::Result<()> { + if let Some(zip) = self.tldr_zip { + let content = if let Some(f) = + get_zip_content(zip, &format!("pages/common/{}.md", self.name)) + { + f + } else if let Some(f) = get_zip_content(zip, &format!("pages/linux/{}.md", self.name)) { + f + } else { + println!( + "Warning: Could not find tldr examples for page '{}'", + self.name + ); + return Ok(()); + }; + + writeln!(self.w, "## Examples")?; + writeln!(self.w)?; + for line in content.lines().skip_while(|l| !l.starts_with('-')) { + if let Some(l) = line.strip_prefix("- ") { + writeln!(self.w, "{}", l)?; + } else if line.starts_with('`') { + writeln!(self.w, "```shell\n{}\n```", line.trim_matches('`'))?; + } else if line.is_empty() { + writeln!(self.w)?; + } else { + println!("Not sure what to do with this line:"); + println!("{}", line); + } + } + writeln!(self.w)?; + writeln!( + self.w, + "> The examples are provided by the [tldr-pages project](https://tldr.sh) under the [CC BY 4.0 License](https://github.com/tldr-pages/tldr/blob/main/LICENSE.md)." + )?; + writeln!(self.w, ">")?; + writeln!( + self.w, + "> Please note that, as uutils is a work in progress, some examples might fail." + )?; + } + Ok(()) + } + + fn options(&mut self) -> io::Result<()> { + writeln!(self.w, "

Options

")?; + write!(self.w, "
")?; + for arg in self.command.get_arguments() { + write!(self.w, "
")?; + let mut first = true; + for l in arg.get_long_and_visible_aliases().unwrap_or_default() { + if first { + first = false; + } else { + write!(self.w, ", ")?; + } + write!(self.w, "")?; + write!(self.w, "--{}", l)?; + if let Some(names) = arg.get_value_names() { + write!( + self.w, + "={}", + names + .iter() + .map(|x| format!("<{}>", x)) + .collect::>() + .join(" ") + )?; + } + write!(self.w, "")?; + } + for s in arg.get_short_and_visible_aliases().unwrap_or_default() { + if first { + first = false; + } else { + write!(self.w, ", ")?; + } + write!(self.w, "")?; + write!(self.w, "-{}", s)?; + if let Some(names) = arg.get_value_names() { + write!( + self.w, + " {}", + names + .iter() + .map(|x| format!("<{}>", x)) + .collect::>() + .join(" ") + )?; + } + write!(self.w, "")?; + } + writeln!(self.w, "
")?; + writeln!( + self.w, + "
\n\n{}\n\n
", + arg.get_help() + .unwrap_or_default() + .to_string() + .replace('\n', "
") + )?; + } + writeln!(self.w, "
\n") + } +} + +fn get_zip_content(archive: &mut ZipArchive, name: &str) -> Option { + let mut s = String::new(); + archive.by_name(name).ok()?.read_to_string(&mut s).unwrap(); + Some(s) +} diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml new file mode 100644 index 0000000..f58b9d9 --- /dev/null +++ b/src/uu/hostname/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "uu_hostname" +version = "0.0.1" +edition = "2021" +authors = ["uutils developers"] +license = "MIT" +description = "hostname ~ (uutils) Execute a program periodically, showing output fullscreen" + +homepage = "https://github.com/uutils/hostname" +repository = "https://github.com/uutils/hostname/tree/main/src/uu/hostname" +keywords = ["acl", "uutils", "cross-platform", "cli", "utility"] +categories = ["command-line-utilities"] + +[dependencies] +uucore = { workspace = true } +clap = { workspace = true } + +[lib] +path = "src/hostname.rs" + +[[bin]] +name = "hostname" +path = "src/main.rs" diff --git a/src/uu/hostname/hostname.md b/src/uu/hostname/hostname.md new file mode 100644 index 0000000..1e65896 --- /dev/null +++ b/src/uu/hostname/hostname.md @@ -0,0 +1,11 @@ +# login + +``` +login [-p] [-h host] [username] [ENV=VAR...] + +login [-p] [-h host] -f username + +login [-p] -r host +``` + +begin session on the system \ No newline at end of file diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs new file mode 100644 index 0000000..475458e --- /dev/null +++ b/src/uu/hostname/src/hostname.rs @@ -0,0 +1,29 @@ +// This file is part of the uutils hostname package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use clap::crate_version; +use clap::{Arg, Command}; +use std::process::{Command as SystemCommand, Stdio}; +use std::thread::sleep; +use std::time::Duration; +use uucore::{error::UResult, format_usage, help_about, help_usage}; + +const ABOUT: &str = help_about!("hostname.md"); +const USAGE: &str = help_usage!("hostname.md"); + +#[uucore::main] +pub fn uumain(args: impl uucore::Args) -> UResult<()> { + let matches = uu_app().try_get_matches_from(args)?; + Ok(()) +} + +pub fn uu_app() -> Command { + Command::new(uucore::util_name()) + .version(crate_version!()) + .about(ABOUT) + .override_usage(format_usage(USAGE)) + .infer_long_args(true) + // TODO +} diff --git a/src/uu/hostname/src/main.rs b/src/uu/hostname/src/main.rs new file mode 100644 index 0000000..09058e4 --- /dev/null +++ b/src/uu/hostname/src/main.rs @@ -0,0 +1 @@ +uucore::bin!(uu_hostname);