Skip to content
Snippets Groups Projects
Commit 6de89a40 authored by Bienchen's avatar Bienchen
Browse files

Set up bash-completion

parent 5de83653
No related branches found
No related tags found
No related merge requests found
...@@ -80,6 +80,7 @@ add_subdirectory(core) ...@@ -80,6 +80,7 @@ add_subdirectory(core)
add_subdirectory(meld) add_subdirectory(meld)
add_subdirectory(scripts) add_subdirectory(scripts)
add_subdirectory(actions) add_subdirectory(actions)
add_subdirectory(extras)
if(NOT DISABLE_DOCUMENTATION) if(NOT DISABLE_DOCUMENTATION)
add_changelog_to_doc(FILE "${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG") add_changelog_to_doc(FILE "${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG")
add_subdirectory(doc) add_subdirectory(doc)
......
...@@ -814,6 +814,7 @@ macro(setup_stage) ...@@ -814,6 +814,7 @@ macro(setup_stage)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${STAGE_DIR}/bin ) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${STAGE_DIR}/bin )
set(HEADER_STAGE_PATH ${STAGE_DIR}/include ) set(HEADER_STAGE_PATH ${STAGE_DIR}/include )
set(SHARED_DATA_PATH ${STAGE_DIR}/share/promod3 ) set(SHARED_DATA_PATH ${STAGE_DIR}/share/promod3 )
set(ETC_STAGE_PATH ${STAGE_DIR}/etc )
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
check_architecture() check_architecture()
...@@ -1036,7 +1037,11 @@ macro(pm_action ACTION TARGET) ...@@ -1036,7 +1037,11 @@ macro(pm_action ACTION TARGET)
if (${PM3_ACTION_NAMES} MATCHES "${stripped_action}") if (${PM3_ACTION_NAMES} MATCHES "${stripped_action}")
set(_ACTION_NAMES "${PM3_ACTION_NAMES}") set(_ACTION_NAMES "${PM3_ACTION_NAMES}")
else() else()
set(_ACTION_NAMES "${PM3_ACTION_NAMES} ${stripped_action}") if("${PM3_ACTION_NAMES}" STREQUAL "")
set(_ACTION_NAMES "${stripped_action}")
else()
set(_ACTION_NAMES "${PM3_ACTION_NAMES} ${stripped_action}")
endif()
endif() endif()
else() else()
set(_ACTION_NAMES "${stripped_action}") set(_ACTION_NAMES "${stripped_action}")
......
# put bash completion in place
# - care for stage directory (etc/bash_completion.d)
# - 'compile' bash completion for pm
# - install
# bash completion file(s)
set(_BC_FILE pm-completion.bash)
# handling bash completion
set(_BC_DIR "${ETC_STAGE_PATH}/bash_completion.d")
set(_ETC_BC_FILE "${_BC_DIR}/${_BC_FILE}")
set(_BC_SUBST_DICT -DINPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${_BC_FILE}.in -DOUT_FILE=${_ETC_BC_FILE} -DPM3_ACTION_NAMES=${PM3_ACTION_NAMES})
add_custom_command(OUTPUT ${_ETC_BC_FILE}
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/CMakeLists.txt"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${_BC_FILE}.in"
COMMAND ${CMAKE_COMMAND} ${_BC_SUBST_DICT}
-P ${CMAKE_SOURCE_DIR}/cmake_support/substitute.cmake)
add_custom_target(bash-completion ALL DEPENDS ${_ETC_BC_FILE})
...@@ -4,7 +4,7 @@ _promod3_completion() ...@@ -4,7 +4,7 @@ _promod3_completion()
# add colour, if supported by terminal # add colour, if supported by terminal
# first check commands # first check commands
local CMD_REPLY=($(compgen -W "build-rawmodel help" -- $cur)) local CMD_REPLY=($(compgen -W "@PM3_ACTION_NAMES@" -- $cur))
# find possible matches in filesystem # find possible matches in filesystem
local FS_REPLY=($(compgen -f -- $cur )) local FS_REPLY=($(compgen -f -- $cur ))
for ((ff=0; ff<${#FS_REPLY[@]}; ff++)); do for ((ff=0; ff<${#FS_REPLY[@]}; ff++)); do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment