1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Bash completion for nit commands
16 # Put (or link) this file into `/etc/bash_completion.d/`
17 # or source it in `~/.bash_completion`.
20 # Check if a valid command
21 which $1 > /dev/null || return 1
23 # Drop possible directories to get the command name
24 local cmd=`basename $1`
26 # Generate the bash-completion
27 # and setup a new `complete` for the command
28 eval "$($1 --bash-completion)"
30 # Special case for `nitg` that uses the completion of `nitc`
31 if test "$cmd" = "nitg"; then
33 complete -F _nitc -o default nitg
36 if [[ $(type -t _$cmd) == function ]]; then
37 # All if fine, finish the job by invoking the function _$cmd
41 # Problem, no function _$cmd
45 complete -F _nit_lazy -o default nit nitc nitdoc nitg nitlight nitls nitmetrics nitunit nitx