aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-28 14:40:49 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-28 14:40:49 +0100
commit1588644f924bb702e56a007be629c54cf14e5e5d (patch)
tree452a702f31988486c19ce4330f6c03283aab9e26
parentadd manpage (diff)
downloadgpp-1588644f924bb702e56a007be629c54cf14e5e5d.tar.gz
gpp-1588644f924bb702e56a007be629c54cf14e5e5d.tar.bz2
gpp-1588644f924bb702e56a007be629c54cf14e5e5d.tar.xz
m + add shell tab-completion
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--Makefile50
-rw-r--r--README2
-rw-r--r--doc/man/gpp.12
-rw-r--r--src/gpp.auto-completion33
4 files changed, 81 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 8ab3ca5..350ba09 100644
--- a/Makefile
+++ b/Makefile
@@ -24,10 +24,10 @@ SHEBANG = /usr$(BIN)/env $(PY)
.PHONY: default
-default: cmd info
+default: cmd info shell
.PHONY: all
-all: cmd doc
+all: cmd doc shell
.PHONY: cmd
cmd: bin/gpp
@@ -78,13 +78,34 @@ obj/fdl.texinfo: doc/info/fdl.texinfo
@mkdir -p obj
cp "$<" "$@"
+.PHONY: shell
+shell: bash fish zsh
+
+.PHONY: bash
+bash: bin/gpp.bash-completion
+
+.PHONY: fish
+fish: bin/gpp.fish-completion
+
+.PHONY: zsh
+zsh: bin/gpp.zsh-completion
+
+obj/gpp.auto-completion: src/gpp.auto-completion bin/gpp
+ @mkdir -p obj
+ cp $< $@
+ $(PY) bin/gpp -s '#' -D GPP=$(COMMAND) < "$<" > "$@"
+
+bin/gpp.%sh-completion: obj/gpp.auto-completion
+ @mkdir -p bin
+ auto-auto-complete $*sh --output $@ --source $<
+
.PHONY: install
-install: install-core install-info install-man
+install: install-core install-info install-man install-shell
.PHONY: install
-install-all: install-core install-doc
+install-all: install-core install-doc install-shell
.PHONY: install-core
install-core: install-cmd install-license
@@ -127,6 +148,24 @@ install-man: doc/man/gpp.1
install -dm755 -- "$(DESTDIR)$(MAN1DIR)"
install -m644 $< -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1"
+.PHONY: install-shell
+install-shell: install-bash install-fish install-zsh
+
+.PHONY: install-bash
+install-bash: bin/gpp.bash-completion
+ install -dm755 -- "$(DESTDIR)$(DATADIR)/bash-completion/completions"
+ install -m644 $< -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
+
+.PHONY: install-fish
+install-fish: bin/gpp.fish-completion
+ install -dm755 -- "$(DESTDIR)$(DATADIR)/fish/completions"
+ install -m644 $< -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
+
+.PHONY: install-zsh
+install-zsh: bin/gpp.zsh-completion
+ install -dm755 -- "$(DESTDIR)$(DATADIR)/zsh/site-functions"
+ install -m644 $< -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
+
.PHONY: uninstall
@@ -140,6 +179,9 @@ uninstall:
-rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).dvi"
-rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).ps"
-rm -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1"
+ -rm -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
+ -rm -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
+ -rm -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
diff --git a/README b/README
index 055d4df..64a6811 100644
--- a/README
+++ b/README
@@ -48,7 +48,7 @@ OPTIONS
Specifies the encoding of the file.
-n, --iterations N
- The the processing N times. Defaults to 1 time.
+ Process the file recursively N times. Defaults to 1 time.
-u, --unshebang
Clear the shebang line, remove it if this flag
diff --git a/doc/man/gpp.1 b/doc/man/gpp.1
index 275a15e..99e820d 100644
--- a/doc/man/gpp.1
+++ b/doc/man/gpp.1
@@ -68,7 +68,7 @@ Defaults to @ (at).
Specifies the encoding of the file.
.TP
.BR \-n ,\ \-\-iterations \ \fIN\fP
-The the processing \fIN\fP times. Defaults to 1 time.
+Process the file recursively \fIN\fP times. Defaults to 1 time.
.TP
.BR \-u ,\ \-\-unshebang
Clear the shebang line, remove it if this flag
diff --git a/src/gpp.auto-completion b/src/gpp.auto-completion
new file mode 100644
index 0000000..6727fb3
--- /dev/null
+++ b/src/gpp.auto-completion
@@ -0,0 +1,33 @@
+(#{GPP}
+ (argumented (option -s --symbol) (complete --symbol) (arg SYMBOL) (files -0)
+ (desc 'Set the prefix symbol for preprocessor directives'))
+
+ (argumented (option -e --encoding) (complete --encoding) (arg ENCODING) (files -0) (suggest encoding)
+ (desc 'Select encoding of the file'))
+ (suggestion encoding (verbatim UTF-8))
+
+ (argumented (option -n --iterations) (complete --iterations) (arg N) (files -0)
+ (desc 'Select the number of times to perform the preprocessing recursively'))
+
+ (unargumented (option -u --unshebang) (complete --unshebang)
+ (desc 'Clear the shebang line, twice to delete it'))
+
+ (argumented (option -i --input) (complete --input) (arg FILE) (files -f)
+ (desc 'Select file to process'))
+
+ (argumented (option -i --output) (complete --output) (arg FILE) (files -f)
+ (desc 'Select output file'))
+
+ (argumented (option -f --file) (complete --file) (arg FILE) (files -r)
+ (desc 'Select file to both process and store the output'))
+
+ (argumented (option -D --export) (complete --export) (arg NAME=VALUE) (files -0)
+ (desc 'Set environment variable'))
+
+ (unargumented (option -v --version) (complete --version)
+ (desc 'Print program name and version and exit'))
+
+ (unargumented (option -c --copying) (complete --copying)
+ (desc 'Print copyright notice and exit'))
+)
+