mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Fix zsh completion arguments (fixes #473)
This commit is contained in:
parent
f0caf5e22d
commit
a9bdeeb0e0
@ -1,3 +1,8 @@
|
||||
2021-01-03 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* Don't include -o nospace with zsh completion setup so file
|
||||
completion works normally. Fixes #473.
|
||||
|
||||
2021-01-02 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* Make QPDFPageObjectHelper methods pipeContents, parseContents,
|
||||
|
5
TODO
5
TODO
@ -1,11 +1,6 @@
|
||||
Candidates for upcoming release
|
||||
===============================
|
||||
|
||||
* Open "next" issues
|
||||
* bugs
|
||||
* #473: zsh completion with directories
|
||||
* Investigate how serverless does completion
|
||||
|
||||
* Remember to check work `qpdf` project for private issues
|
||||
* file with very slow page extraction
|
||||
* big page even with --remove-unreferenced-resources=yes, even with --empty
|
||||
|
@ -5021,6 +5021,12 @@ print "\n";
|
||||
was broken for pages with multiple content streams.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Tweak zsh completion code to behave a little better with
|
||||
respect to path completion.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
35
qpdf/qpdf.cc
35
qpdf/qpdf.cc
@ -726,6 +726,8 @@ class ArgParser
|
||||
OptionEntry oe_optionalParameter(param_arg_handler_t);
|
||||
OptionEntry oe_requiredChoices(param_arg_handler_t, char const** choices);
|
||||
|
||||
void completionCommon(bool zsh);
|
||||
|
||||
void argHelp();
|
||||
void argVersion();
|
||||
void argCopyright();
|
||||
@ -1637,7 +1639,7 @@ ArgParser::argHelp()
|
||||
}
|
||||
|
||||
void
|
||||
ArgParser::argCompletionBash()
|
||||
ArgParser::completionCommon(bool zsh)
|
||||
{
|
||||
std::string progname = argv[0];
|
||||
std::string executable;
|
||||
@ -1657,8 +1659,16 @@ ArgParser::argCompletionBash()
|
||||
progname = appimage;
|
||||
}
|
||||
}
|
||||
std::cout << "complete -o bashdefault -o default -o nospace"
|
||||
<< " -C " << progname << " " << whoami << std::endl;
|
||||
if (zsh)
|
||||
{
|
||||
std::cout << "autoload -U +X bashcompinit && bashcompinit && ";
|
||||
}
|
||||
std::cout << "complete -o bashdefault -o default";
|
||||
if (! zsh)
|
||||
{
|
||||
std::cout << " -o nospace";
|
||||
}
|
||||
std::cout << " -C " << progname << " " << whoami << std::endl;
|
||||
// Put output before error so calling from zsh works properly
|
||||
std::string path = progname;
|
||||
size_t slash = path.find('/');
|
||||
@ -1669,11 +1679,16 @@ ArgParser::argCompletionBash()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArgParser::argCompletionBash()
|
||||
{
|
||||
completionCommon(false);
|
||||
}
|
||||
|
||||
void
|
||||
ArgParser::argCompletionZsh()
|
||||
{
|
||||
std::cout << "autoload -U +X bashcompinit && bashcompinit && ";
|
||||
argCompletionBash();
|
||||
completionCommon(true);
|
||||
}
|
||||
void
|
||||
ArgParser::argJsonHelp()
|
||||
@ -3373,10 +3388,20 @@ ArgParser::addOptionsToCompletions()
|
||||
iter != this->option_table->end(); ++iter)
|
||||
{
|
||||
std::string const& arg = (*iter).first;
|
||||
if (arg == "--")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
OptionEntry& oe = (*iter).second;
|
||||
std::string base = "--" + arg;
|
||||
if (oe.param_arg_handler)
|
||||
{
|
||||
if (zsh_completion)
|
||||
{
|
||||
// zsh doesn't treat = as a word separator, so add all
|
||||
// the options so we don't get a space after the =.
|
||||
addChoicesToCompletions(arg, base + "=");
|
||||
}
|
||||
completions.insert(base + "=");
|
||||
}
|
||||
if (! oe.parameter_needed)
|
||||
|
2
qpdf/qtest/qpdf/completion-decode-l-zsh.out
Normal file
2
qpdf/qtest/qpdf/completion-decode-l-zsh.out
Normal file
@ -0,0 +1,2 @@
|
||||
--decode-level=all
|
||||
!--help
|
4
qpdf/qtest/qpdf/completion-encrypt-40-zsh.out
Normal file
4
qpdf/qtest/qpdf/completion-encrypt-40-zsh.out
Normal file
@ -0,0 +1,4 @@
|
||||
--annotate=n
|
||||
!----
|
||||
!--force-R5
|
||||
!--force-V4
|
@ -1,3 +1,4 @@
|
||||
--annotate=
|
||||
!----
|
||||
!--force-R5
|
||||
!--force-V4
|
||||
|
7
qpdf/qtest/qpdf/completion-later-arg-zsh.out
Normal file
7
qpdf/qtest/qpdf/completion-later-arg-zsh.out
Normal file
@ -0,0 +1,7 @@
|
||||
--check
|
||||
--decode-level=all
|
||||
--encrypt
|
||||
!--completion-bash
|
||||
!--copyright
|
||||
!--help
|
||||
!--version
|
7
qpdf/qtest/qpdf/completion-top-arg-zsh.out
Normal file
7
qpdf/qtest/qpdf/completion-top-arg-zsh.out
Normal file
@ -0,0 +1,7 @@
|
||||
--check
|
||||
--completion-bash
|
||||
--copyright
|
||||
--decode-level=none
|
||||
--encrypt
|
||||
--help
|
||||
--version
|
Loading…
Reference in New Issue
Block a user