Skip to content
Snippets Groups Projects
Commit 55da427f authored by Millian Poquet's avatar Millian Poquet
Browse files

[misc] bash (and zsh) completion

enable completion in bash:
source ${BATSCHED_DIR}/bash_completion.sh
(calls batsched --complete when TAB is pressed)

enable completion in zsh:
compdef _gnu_generic batsched
(calls batsched --help (once?) to generate a completion script)
parent feeecb43
Branches
No related tags found
No related merge requests found
_filedir_batsched() {
_init_completion -n 2> /dev/null
local program comparg
program="${COMP_WORDS[0]}"
comparg="--complete" # replace this with your flag
COMPREPLY=($("$program" "$comparg" bash "$COMP_CWORD" "${COMP_WORDS[@]}" 2> /dev/null))
[[ $COMPREPLY ]] && return
_filedir
}
complete -F _filedir_batsched batsched
......@@ -73,6 +73,8 @@ int main(int argc, char ** argv)
args::ArgumentParser parser("A Batsim-compatible scheduler in C++.");
args::HelpFlag flag_help(parser, "help", "Display this help menu", {'h', "help"});
args::CompletionFlag completion(parser, {"complete"});
args::ValueFlag<double> flag_rjms_delay(parser, "delay", "Sets the expected time that the RJMS takes to do some things like killing a job", {'d', "rjms_delay"}, 5.0);
args::ValueFlag<string> flag_selection_policy(parser, "policy", "Sets the resource selection policy. Available values are " + policies_string, {'p', "policy"}, "basic");
args::ValueFlag<string> flag_socket_endpoint(parser, "endpoint", "Sets the socket endpoint.", {'s', "socket-endpoint"}, "tcp://*:28000");
......@@ -110,6 +112,11 @@ int main(int argc, char ** argv)
printf("%s", parser.Help().c_str());
return 0;
}
catch (args::Completion & e)
{
printf("%s", e.what());
return 0;
}
catch(args::ParseError e)
{
printf("%s\n", e.what());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment