Skip to content

Commit

Permalink
close #231
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu committed Dec 29, 2020
1 parent 4ed652e commit 87e0c65
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ clean-local-check:
utilities: utilities/dataExplore.r utilities/interpretDEploid.r
sed -i'.bak' -e '/#!\/usr\/bin\/env Rscript/d' -e '/rm(list=ls())/d' utilities/dataExplore.r ; echo "#!/usr/bin/env Rscript" > tmpTxt; echo "rm(list=ls()); dEploidRootDir=\"$(PWD)\"" >> tmpTxt ; cat utilities/dataExplore.r >> tmpTxt ; mv tmpTxt utilities/dataExplore.r; chmod a+x utilities/dataExplore.r;
sed -i'.bak' -e '/#!\/usr\/bin\/env Rscript/d' -e '/rm(list=ls())/d' utilities/interpretDEploid.r; echo "#!/usr/bin/env Rscript" > tmpTxt; echo "rm(list=ls()); dEploidRootDir=\"$(PWD)\"" >> tmpTxt ; cat utilities/interpretDEploid.r >> tmpTxt ; mv tmpTxt utilities/interpretDEploid.r; chmod a+x utilities/interpretDEploid.r


if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
dist_bashcompletion_DATA = dEploid_completion.sh
endif

19 changes: 19 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ AC_TYPE_SIZE_T
#AC_SUBST(OPT_CXXFLAGS)
#fi

# bash complete
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
[Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
[],
[with_bash_completion_dir=yes])

if test "x$with_bash_completion_dir" = "xyes"; then
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
[BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
else
BASH_COMPLETION_DIR="$with_bash_completion_dir"
fi

AC_SUBST([BASH_COMPLETION_DIR])
AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"])


# Enable Warnings
AX_CXXFLAGS_WARN_ALL
#AX_CHECK_COMPILE_FLAG([-Wextra], [OPT_CXXFLAGS="$OPT_CXXFLAGS -Wextra"], [], [-Werror])
Expand Down
41 changes: 41 additions & 0 deletions dEploid_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#/usr/bin/env bash

_dEploid_completions()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-h -help \
-ref -alt -plaf -panel -exclude\
-vcf -sample -plafFromVcf \
-o -seed -noPanel\
-ibd -lasso -best"


if [[ ${cur} == -* || ${prev} == "dEploid" ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
else
if [[ ${prev} == "-ref" || ${prev} == "-alt" || ${prev} == "-plaf" || ${prev} == "-panel" || ${prev} == "-exclude" ]] ; then
COMPREPLY=( $(compgen -o plusdirs -f -X '!*.@(txt|gz)' -- ${cur}) )
for ((i=0; i < ${#COMPREPLY[@]}; i++)); do
[ -d "${COMPREPLY[$i]}" ] && COMPREPLY[$i]=${COMPREPLY[$i]}/
done
return 0
else
if [[ ${prev} == "-vcf" ]] ; then
COMPREPLY=( $(compgen -o plusdirs -f -X '!*.@(vcf|gz)' -- ${cur}) )
for ((i=0; i < ${#COMPREPLY[@]}; i++)); do
[ -d "${COMPREPLY[$i]}" ] && COMPREPLY[$i]=${COMPREPLY[$i]}/
done
return 0
else
return 0
fi
fi
fi
return 0
}

complete -o filenames -o nospace -o bashdefault -F _dEploid_completions dEploid

0 comments on commit 87e0c65

Please sign in to comment.