mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Bash completion
This commit is contained in:
parent
67a0514704
commit
ca0fdcd5c9
@ -159,11 +159,23 @@ QString arguments::rst()
|
||||
return s;
|
||||
}
|
||||
|
||||
QString arguments::completion()
|
||||
{
|
||||
QStringList sl;
|
||||
for (auto i = opts.begin(); i != opts.end(); ++i)
|
||||
sl << QString("--%1").arg(i->long_opt);
|
||||
return sl.join(" ");
|
||||
}
|
||||
|
||||
QString arguments::doc(const QString &which)
|
||||
{
|
||||
if (which == "rst")
|
||||
return rst();
|
||||
return man();
|
||||
if (which == "man")
|
||||
return man();
|
||||
if (which == "completion")
|
||||
return completion();
|
||||
return QString();
|
||||
}
|
||||
|
||||
size_t arguments::maxOptWidth()
|
||||
|
||||
@ -50,6 +50,7 @@ class arguments
|
||||
static QString help();
|
||||
static QString man();
|
||||
static QString rst();
|
||||
static QString completion();
|
||||
static size_t maxOptWidth();
|
||||
static QString doc(const QString &which);
|
||||
|
||||
|
||||
@ -300,9 +300,9 @@ static void read_cmdline(int argc, char *argv[])
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *xca_man = getenv("XCA_MAN");
|
||||
if (xca_man && *xca_man) {
|
||||
puts(CCHAR(arguments::doc(xca_man)));
|
||||
const char *xca_special = getenv("XCA_SPECIAL");
|
||||
if (xca_special && *xca_special) {
|
||||
puts(CCHAR(arguments::doc(xca_special)));
|
||||
return 0;
|
||||
}
|
||||
#if QT_VERSION < 0x050000
|
||||
|
||||
@ -27,11 +27,13 @@ endif
|
||||
install:
|
||||
install -m 755 -d $(DESTDIR)$(xca_prefix) \
|
||||
$(DESTDIR)$(datarootdir)/applications \
|
||||
$(DESTDIR)$(datarootdir)/mime/packages
|
||||
$(DESTDIR)$(datarootdir)/mime/packages \
|
||||
$(DESTDIR)$(datarootdir)/bash-completion/completions
|
||||
install -m 644 $(CONFIG_OBJ) $(SRCPATH)*.xca \
|
||||
$(DESTDIR)$(xca_prefix)
|
||||
install -m 644 $(SRCPATH)xca.desktop $(DESTDIR)$(datarootdir)/applications
|
||||
install -m 644 $(SRCPATH)xca.xml $(DESTDIR)$(datarootdir)/mime/packages
|
||||
install -m 644 $(SRCPATH)xca.completion $(DESTDIR)$(datarootdir)/bash-completion/completions/xca
|
||||
if test -z "$(DESTDIR)"; then \
|
||||
update-mime-database $(datarootdir)/mime || :; \
|
||||
update-desktop-database || :; \
|
||||
|
||||
6
misc/xca.completion
Normal file
6
misc/xca.completion
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
_XCA_WORDS="$(XCA_SPECIAL=completion xca)"
|
||||
_xca() {
|
||||
COMPREPLY=($(compgen -o bashdefault -W "$_XCA_WORDS" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
}
|
||||
complete -F _xca xca
|
||||
Loading…
Reference in New Issue
Block a user