Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash completion for flags #392

Merged
merged 18 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generate a the ruby script.
# Generate the ruby script.
# Note that the major version of the library is included in the name.
if (APPLE)
set(IGN_LIBRARY_NAME lib${PROJECT_NAME_LOWER}.dylib)
Expand All @@ -11,3 +11,6 @@ configure_file(

# Install the ruby command line library in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition)

# Install the bash completion script in an unversioned location.
install(FILES gui.bash_completion.sh DESTINATION share/ignition/ignition.completion.d)
29 changes: 29 additions & 0 deletions src/cmd/gui.bash_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
mabelzhang marked this conversation as resolved.
Show resolved Hide resolved

# bash tab-completion

# This is a per-library function definition, used in conjunction with the
# top-level entry point in ign-tools.

function _gz_gui
{
if [[ ${COMP_WORDS[COMP_CWORD]} == -* ]]; then
# Specify options (-*) word list for this subcommand
COMPREPLY=($(compgen -W "
-l --list
-s --standalone
-c --config
-v --verbose
-h --help
--force-version
--versions
" -- "${COMP_WORDS[COMP_CWORD]}" ))
return
else
# Just use bash default auto-complete, because we never have two
# subcommands in the same line. If that is ever needed, change here to
# detect subsequent subcommands
COMPREPLY=($(compgen -o default -- "${COMP_WORDS[COMP_CWORD]}"))
return
fi
}