[DEV] add autocompletion for lutin.py
This commit is contained in:
parent
ec60375c9f
commit
9d6418eed9
90
bash-autocompletion/lutin.py
Executable file
90
bash-autocompletion/lutin.py
Executable file
@ -0,0 +1,90 @@
|
||||
_lutin()
|
||||
{
|
||||
local cur prev optshorts opts renameprev listmodule
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
optshorts="-h -v -C -f -P -j -s -t -c -m -r -p"
|
||||
opts="--help --verbose --color --force --pretty --jobs --force-strip --target --compilator --mode --prj --package --simulation"
|
||||
|
||||
renameprev=${prev}
|
||||
case "${renameprev}" in
|
||||
-h)
|
||||
renameprev="--help"
|
||||
;;
|
||||
-v)
|
||||
renameprev="--verbose"
|
||||
;;
|
||||
-C)
|
||||
renameprev="--color"
|
||||
;;
|
||||
-f)
|
||||
renameprev="--force"
|
||||
;;
|
||||
-P)
|
||||
renameprev="--pretty"
|
||||
;;
|
||||
-j)
|
||||
renameprev="--jobs"
|
||||
;;
|
||||
-s)
|
||||
renameprev="--force-strip"
|
||||
;;
|
||||
-t)
|
||||
renameprev="--target"
|
||||
;;
|
||||
-c)
|
||||
renameprev="--compilator"
|
||||
;;
|
||||
-m)
|
||||
renameprev="--mode"
|
||||
;;
|
||||
-r)
|
||||
renameprev="--prj"
|
||||
;;
|
||||
-p)
|
||||
renameprev="--package"
|
||||
;;
|
||||
esac
|
||||
#
|
||||
# Complete the arguments to some of the basic commands.
|
||||
#
|
||||
case "${renameprev}" in
|
||||
--compilator)
|
||||
local names="clang gcc"
|
||||
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--jobs)
|
||||
local names="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
|
||||
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--target)
|
||||
local names=`lutin.py --list-target`
|
||||
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--mode)
|
||||
local names="debug release"
|
||||
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ${cur} == --* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
if [[ ${cur} == -* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${optshorts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
listmodule=`lutin.py --list-module`
|
||||
COMPREPLY=( $(compgen -W "${listmodule}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _lutin lutin.py
|
6
bash-autocompletion/readme
Normal file
6
bash-autocompletion/readme
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
to install autocompletion for lutin :
|
||||
|
||||
sudo cp bash-autocompletion/lutin.py /etc/bash_completion.d
|
||||
|
||||
==> and restart bash ...
|
24
lutin.py
24
lutin.py
@ -27,6 +27,8 @@ myLutinArg.add(lutinArg.ArgDefine("m", "mode", list=[["debug",""],["release",""]
|
||||
myLutinArg.add(lutinArg.ArgDefine("r", "prj", desc="Use external project management (not build with lutin..."))
|
||||
myLutinArg.add(lutinArg.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("", "simulation", desc="simulater mode (availlable only for IOS)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("", "list-target", desc="list all availlables targets ==> for auto completion"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("", "list-module", desc="list all availlables module ==> for auto completion"))
|
||||
|
||||
myLutinArg.add_section("cible", "generate in order set")
|
||||
localArgument = myLutinArg.parse()
|
||||
@ -58,6 +60,28 @@ def parseGenericArg(argument,active):
|
||||
if active==False:
|
||||
usage()
|
||||
return True
|
||||
if argument.get_option_nName() == "list-module":
|
||||
if active==False:
|
||||
listOfModule = lutinModule.list_all_module()
|
||||
retValue = ""
|
||||
for moduleName in listOfModule:
|
||||
if retValue != "":
|
||||
retValue += " "
|
||||
retValue += moduleName
|
||||
print retValue
|
||||
exit(0)
|
||||
return True
|
||||
if argument.get_option_nName() == "list-target":
|
||||
if active==False:
|
||||
listOfTarget = lutinTarget.list_all_target()
|
||||
retValue = ""
|
||||
for targetName in listOfTarget:
|
||||
if retValue != "":
|
||||
retValue += " "
|
||||
retValue += targetName
|
||||
print retValue
|
||||
exit(0)
|
||||
return True
|
||||
elif argument.get_option_nName()=="jobs":
|
||||
if active==True:
|
||||
lutinMultiprocess.set_core_number(int(argument.get_arg()))
|
||||
|
@ -323,6 +323,10 @@ class Target:
|
||||
|
||||
__startTargetName="lutinTarget"
|
||||
|
||||
def list_all_target():
|
||||
tmpListName = ["Android", "Linux", "MacOs", "IOs", "Windows" ]
|
||||
return tmpListName
|
||||
|
||||
def target_load(targetName, compilator, mode, generatePackage, externBuild, simulationMode):
|
||||
theTarget = __import__(__startTargetName + targetName)
|
||||
#try:
|
||||
|
Loading…
Reference in New Issue
Block a user