Skip to content

Commit 94e1023

Browse files
authored
Merge pull request #8513 from aaron-ang/migrate-manpage
uudoc: move manpage and completions generation out of binary
2 parents 8d891bb + 2919027 commit 94e1023

File tree

17 files changed

+536
-367
lines changed

17 files changed

+536
-367
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ expensive_tests = []
3131
# "test_risky_names" == enable tests that create problematic file names (would make a network share inaccessible to Windows, breaks SVN on Mac OS, etc.)
3232
test_risky_names = []
3333
# * only build `uudoc` when `--feature uudoc` is activated
34-
uudoc = ["zip", "dep:fluent-syntax"]
34+
uudoc = ["clap_complete", "clap_mangen", "fluent-syntax", "zip", "feat_Tier1"]
3535
## features
3636
## Optional feature for stdbuf
3737
# "feat_external_libstdbuf" == use an external libstdbuf.so for stdbuf instead of embedding it
@@ -408,14 +408,14 @@ uutests = { version = "0.3.0", package = "uutests", path = "tests/uutests" }
408408

409409
[dependencies]
410410
clap.workspace = true
411-
uucore.workspace = true
412-
clap_complete.workspace = true
413-
clap_mangen.workspace = true
411+
clap_complete = { workspace = true, optional = true }
412+
clap_mangen = { workspace = true, optional = true }
413+
fluent-syntax = { workspace = true, optional = true }
414414
phf.workspace = true
415415
selinux = { workspace = true, optional = true }
416416
textwrap.workspace = true
417+
uucore.workspace = true
417418
zip = { workspace = true, optional = true }
418-
fluent-syntax = { workspace = true, optional = true }
419419

420420

421421
# * uutils

GNUmakefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ TEST_PROGS := \
302302
unexpand \
303303
uniq \
304304
unlink \
305+
uudoc \
305306
wc \
306307
who
307308

@@ -406,10 +407,13 @@ distclean: clean
406407
$(CARGO) clean $(CARGOFLAGS) && $(CARGO) update $(CARGOFLAGS)
407408

408409
ifeq ($(MANPAGES),y)
409-
manpages: build-coreutils
410+
build-uudoc:
411+
${CARGO} build ${CARGOFLAGS} --bin uudoc --features "uudoc ${EXES}" ${PROFILE_CMD} --no-default-features
412+
413+
manpages: build-coreutils build-uudoc
410414
mkdir -p $(BUILDDIR)/man/
411415
$(foreach prog, $(INSTALLEES) $(HASHSUM_PROGS), \
412-
$(BUILDDIR)/coreutils manpage $(prog) > $(BUILDDIR)/man/$(PROG_PREFIX)$(prog).1 $(newline) \
416+
$(BUILDDIR)/uudoc manpage $(prog) > $(BUILDDIR)/man/$(PROG_PREFIX)$(prog).1 $(newline) \
413417
)
414418

415419
install-manpages: manpages
@@ -422,12 +426,12 @@ install-manpages:
422426
endif
423427

424428
ifeq ($(COMPLETIONS),y)
425-
completions: build-coreutils
429+
completions: build-coreutils build-uudoc
426430
mkdir -p $(BUILDDIR)/completions/zsh $(BUILDDIR)/completions/bash $(BUILDDIR)/completions/fish
427431
$(foreach prog, $(INSTALLEES) $(HASHSUM_PROGS) , \
428-
$(BUILDDIR)/coreutils completion $(prog) zsh > $(BUILDDIR)/completions/zsh/_$(PROG_PREFIX)$(prog) $(newline) \
429-
$(BUILDDIR)/coreutils completion $(prog) bash > $(BUILDDIR)/completions/bash/$(PROG_PREFIX)$(prog) $(newline) \
430-
$(BUILDDIR)/coreutils completion $(prog) fish > $(BUILDDIR)/completions/fish/$(PROG_PREFIX)$(prog).fish $(newline) \
432+
$(BUILDDIR)/uudoc completion $(prog) zsh > $(BUILDDIR)/completions/zsh/_$(PROG_PREFIX)$(prog) $(newline) \
433+
$(BUILDDIR)/uudoc completion $(prog) bash > $(BUILDDIR)/completions/bash/$(PROG_PREFIX)$(prog) $(newline) \
434+
$(BUILDDIR)/uudoc completion $(prog) fish > $(BUILDDIR)/completions/fish/$(PROG_PREFIX)$(prog).fish $(newline) \
431435
)
432436

433437
install-completions: completions
@@ -520,4 +524,4 @@ endif
520524
rm -f $(addprefix $(DESTDIR)$(DATAROOTDIR)/fish/vendor_completions.d/$(PROG_PREFIX),$(addsuffix .fish,$(PROGS)))
521525
rm -f $(addprefix $(DESTDIR)$(DATAROOTDIR)/man/man1/$(PROG_PREFIX),$(addsuffix .1,$(PROGS)))
522526

523-
.PHONY: all build build-coreutils build-pkgs test distclean clean busytest install uninstall
527+
.PHONY: all build build-coreutils build-pkgs build-uudoc test distclean clean busytest install uninstall

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,33 +252,41 @@ The `coreutils` binary can generate completions for the `bash`, `elvish`,
252252
The syntax is:
253253

254254
```shell
255-
cargo run completion <utility> <shell>
255+
# Install uudoc first
256+
cargo install --bin uudoc --features uudoc --path .
257+
258+
# Then use the installed binary
259+
uudoc completion <utility> <shell>
256260
```
257261

258262
So, to install completions for `ls` on `bash` to
259263
`/usr/local/share/bash-completion/completions/ls`, run:
260264

261265
```shell
262-
cargo run completion ls bash > /usr/local/share/bash-completion/completions/ls
266+
uudoc completion ls bash > /usr/local/share/bash-completion/completions/ls
263267
```
264268

265269
Completion for prefixed `cp` with `uu-` on `zsh` is generated by
266270
```shell
267-
env PROG_PREFIX=uu- cargo run completion cp zsh
271+
env PROG_PREFIX=uu- uudoc completion cp zsh
268272
```
269273

270274
### Manually install manpages
271275

272276
To generate manpages, the syntax is:
273277

274278
```bash
275-
cargo run manpage <utility>
279+
# Install uudoc first
280+
cargo install --bin uudoc --features uudoc --path .
281+
282+
# Then use the installed binary
283+
uudoc manpage <utility>
276284
```
277285

278286
So, to install the manpage for `ls` to `/usr/local/share/man/man1/ls.1` run:
279287

280288
```bash
281-
cargo run manpage ls > /usr/local/share/man/man1/ls.1
289+
uudoc manpage ls > /usr/local/share/man/man1/ls.1
282290
```
283291

284292
## Un-installation

build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
// spell-checker:ignore (vars) krate
6+
// spell-checker:ignore (vars) krate mangen
77

88
use std::env;
99
use std::fs::File;
@@ -32,7 +32,8 @@ pub fn main() {
3232
// Allow this as we have a bunch of info in the comments
3333
#[allow(clippy::match_same_arms)]
3434
match krate.as_ref() {
35-
"default" | "macos" | "unix" | "windows" | "selinux" | "zip" => continue, // common/standard feature names
35+
"default" | "macos" | "unix" | "windows" | "selinux" | "zip" | "clap_complete"
36+
| "clap_mangen" | "fluent_syntax" => continue, // common/standard feature names
3637
"nightly" | "test_unimplemented" | "expensive_tests" | "test_risky_names" => {
3738
continue;
3839
} // crate-local custom features

fuzz/Cargo.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)