Skip to content

Straight port of fish-shell's Python manpage completion script to Rust

Notifications You must be signed in to change notification settings

rust-dc/fish-manpage-completions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fish-manpage-completions

Build Status

Port! Not Starboard! From Python to Rust!

Current status

It works(!), although there might be minor recent enhancements to the upstream Python original missing from this version.

Install

Having already installed Rust as noted below, run

cargo install --locked --path .

at the top-level of this repo.

Using

Once installed, run

fish-manpage-completions \
  --manpath \
  --directory ~/.local/share/fish/generated_completions \
  --progress

You can also, of course, redefine fish's built-in fish_update_completions function to use this rather than the original Python source.

function fish_update_completions
  fish-manpage-completions \
    --manpath \
    --directory ~/.local/share/fish/generated_completions \
    --progress
end

funcsave fish_update_completions

Contributing

For in-depth discussion of a particularly hairy function, open a dedicated issue or pipe up on the RustDC Zulip chat.

Getting Started

Cargo and rustc are a prerequisite, to install check https://rustup.rs/.

To build and run tests.

cargo test

Examples

The following initial snippet of the tr program's manpage

.Dd July 23, 2004
.Dt TR 1
.Os
.Sh NAME
.Nm tr
.Nd translate characters
.Sh SYNOPSIS
.Nm
.Op Fl Ccsu
.Ar string1 string2
.Nm
.Op Fl Ccu
.Fl d
.Ar string1
.Nm
.Op Fl Ccu
.Fl s
.Ar string1
.Nm
.Op Fl Ccu
.Fl ds
.Ar string1 string2
.Sh DESCRIPTION
The
.Nm
utility copies the standard input to the standard output with substitution
or deletion of selected characters.
.Pp
The following options are available:
.Bl -tag -width Ds
.It Fl C
Complement the set of characters in
.Ar string1 ,
that is
.Dq Fl C Li ab
includes every character except for
.Ql a
and
.Ql b .
.It Fl c
Same as
.Fl C
but complement the set of values in
.Ar string1 .
.It Fl d
Delete characters in
.Ar string1
from the input.
.It Fl s
Squeeze multiple occurrences of the characters listed in the last
operand (either
.Ar string1
or
.Ar string2 )
in the input into a single instance of the character.
This occurs after all deletion and translation is completed.
.It Fl u
Guarantee that any output is unbuffered.

is parsed, and the description extracted to form part of the simple completion available.

Piped through

cat PATH/TO/TR.1 | cargo run -- --stdout

will eventually (when we get enough functionality ported) yield the following

# Autogenerated from man page STDIN
complete -c tr -s u --description 'Guarantee that any output is unbuffered.'

Passing this as source into fish will cause this description to be displayed when fish shows tr as an auto-completeable command.

About

Straight port of fish-shell's Python manpage completion script to Rust

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published