diff --git a/bash-autocompletion/lutin.py b/bash-autocompletion/lutin.py new file mode 100755 index 0000000..9ad80c7 --- /dev/null +++ b/bash-autocompletion/lutin.py @@ -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 \ No newline at end of file diff --git a/bash-autocompletion/readme b/bash-autocompletion/readme new file mode 100644 index 0000000..e89ef7a --- /dev/null +++ b/bash-autocompletion/readme @@ -0,0 +1,6 @@ + +to install autocompletion for lutin : + +sudo cp bash-autocompletion/lutin.py /etc/bash_completion.d + +==> and restart bash ... diff --git a/lutin.py b/lutin.py index 29bca04..732173c 100755 --- a/lutin.py +++ b/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())) diff --git a/lutinTarget.py b/lutinTarget.py index d99895f..d48df4e 100644 --- a/lutinTarget.py +++ b/lutinTarget.py @@ -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: