Skip to content

Commit

Permalink
Fix completion script for output from more recent cmdliners
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr committed Apr 14, 2017
1 parent cdaceb5 commit 1ed4880
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions shell/opam_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ _opam_add_f()
_opam_flags()
{
opam "$@" --help=groff 2>/dev/null | \
sed -n -e 's%\\-%-%g' -e 's%, \\fB%\n\\fB%g' -e '/^\\fB-/p' | \
sed -n \
-e 's%\\-\|\\N'"'45'"'%-%g' \
-e 's%, \\fB%\n\\fB%g' \
-e '/^\\fB-/p' | \
sed -e 's%^\\fB\(-[^\\]*\).*%\1%'
}

_opam_commands()
{
opam "$@" --help=groff 2>/dev/null | \
sed -n \
-e 's%\\-%-%g' \
-e 's%\\-\|\\N'"'45'"'%-%g' \
-e '/^\.SH COMMANDS$/,/^\.SH/ s%^\\fB\([^,= ]*\)\\fR.*%\1%p'
echo '--help'
}
Expand All @@ -45,7 +48,7 @@ _opam_argtype()
-*)
opam "$cmd" --help=groff 2>/dev/null | \
sed -n \
-e 's%\\-%-%g' \
-e 's%\\-\|\\N'"'45'"'%-%g' \
-e 's%.*\\fB'"$flag"'\\fR[= ]\\fI\([^, ]*\)\\fR.*%\1%p'
;;
esac
Expand Down
9 changes: 6 additions & 3 deletions shell/opam_completion_zsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ _opam_add_f()
_opam_flags()
{
opam "$@" --help=groff 2>/dev/null | \
sed -n -e 's%\\-%-%g' -e 's%, \\fB%\n\\fB%g' -e '/^\\fB-/p' | \
sed -n \
-e 's%\\-\|\\N'"'45'"'%-%g' \
-e 's%, \\fB%\n\\fB%g' \
-e '/^\\fB-/p' | \
sed -e 's%^\\fB\(-[^\\]*\).*%\1%'
}

_opam_commands()
{
opam "$@" --help=groff 2>/dev/null | \
sed -n \
-e 's%\\-%-%g' \
-e 's%\\-\|\\N'"'45'"'%-%g' \
-e '/^\.SH COMMANDS$/,/^\.SH/ s%^\\fB\([^,= ]*\)\\fR.*%\1%p'
echo '--help'
}
Expand All @@ -47,7 +50,7 @@ _opam_argtype()
-*)
opam "$cmd" --help=groff 2>/dev/null | \
sed -n \
-e 's%\\-%-%g' \
-e 's%\\-\|\\N'"'45'"'%-%g' \
-e 's%.*\\fB'"$flag"'\\fR[= ]\\fI\([^, ]*\)\\fR.*%\1%p'
;;
esac
Expand Down

0 comments on commit 1ed4880

Please sign in to comment.