Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Closes #5
Browse files Browse the repository at this point in the history
- Added a completion script for very basic bash completion
- Fixed a clang compiler error #2

Merge branch 'fberlakovich-general-improvements'
  • Loading branch information
Markus Raab committed Jul 11, 2014
2 parents 4bd0d85 + 97588de commit effff56
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
41 changes: 41 additions & 0 deletions scripts/kdb-bash-completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
###########################################################################
##
## This script sets up basic bash completion for the kdb command
##
##
## Put it under /etc/bash_completion.d or load it just for the current
## session with . <scriptname>
##
###########################################################################


_kdb ()
{
local cur commands
COMPREPLY=()

# assign the currently active word
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

# initialize
kdbpath=$(which kdb)
commands=$(${kdbpath} 2>&1 | sed -e '0,/^Known commands are/d' | awk '{print $1}' | tr '\n' ' ')
pathcommands="export file get getmeta cp ls lsmeta mv rm set setmeta sget vset"

# only kdb was entered yet, print a list of available commands
if [[ $COMP_CWORD -le 1 ]]; then
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
fi

# a command which expects a path as its first parameter was entered
if [[ $pathcommands =~ $prev ]]; then
paths=$( { ${kdbpath} ls system && ${kdbpath} ls user; } | tr '\n' ' ')
COMPREPLY=( $(compgen -W "${paths}" -- ${cur}) )
return 0;
fi
}

# complete the command with _kdb and fall back to filename completion
complete -o default -F _kdb kdb
2 changes: 1 addition & 1 deletion src/libtools/include/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Backend
void tryPlugin (std::string name);

public:
Backend(std::string name, std::string mountpoint);
Backend(std::string name = "", std::string mountpoint = "");
~Backend();

void addPlugin (std::string name);
Expand Down
2 changes: 1 addition & 1 deletion src/libtools/src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace tools
/** Creates a new backend with a given name and mountpoint.
* Parameters are needed for serialisation only, so you can
* keep them empty if you do not want to serialise. */
Backend::Backend(string name_ = "", string mp_ = "") :
Backend::Backend(string name_, string mp_) :
name(name_), mp(mp_)
{
}
Expand Down

0 comments on commit effff56

Please sign in to comment.