Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions bin/reframe
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK
#
# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
# ReFrame Project Developers. See the top-level LICENSE file for details.
Expand Down
10 changes: 10 additions & 0 deletions docs/started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ All you need is a Python 3.6+ installation with ``pip``:
For previous ReFrame versions you should install its requirements using ``pip install -r requirements.txt`` in a Python virtual environment.


Enabling auto-completion
------------------------

.. versionadded:: 3.4.1

You can enable auto-completion for ReFrame by sourcing in your shell the corresponding script in ``<install_prefix>/etc/reframe_completion.<shell>``.
Auto-completion is supported for Bash, Tcsh and Fish shells.



Running the Unit Tests
----------------------

Expand Down
46 changes: 46 additions & 0 deletions etc/reframe_completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# Run something, muting output or redirecting it to the debug stream
# depending on the value of _ARC_DEBUG.
# If ARGCOMPLETE_USE_TEMPFILES is set, use tempfiles for IPC.
__python_argcomplete_run() {
if [[ -z "${ARGCOMPLETE_USE_TEMPFILES-}" ]]; then
__python_argcomplete_run_inner "$@"
return
fi
local tmpfile="$(mktemp)"
_ARGCOMPLETE_STDOUT_FILENAME="$tmpfile" __python_argcomplete_run_inner "$@"
local code=$?
cat "$tmpfile"
rm "$tmpfile"
return $code
}

__python_argcomplete_run_inner() {
if [[ -z "${_ARC_DEBUG-}" ]]; then
"$@" 8>&1 9>&2 1>/dev/null 2>&1
else
"$@" 8>&1 9>&2 1>&9 2>&1
fi
}

_python_argcomplete() {
local IFS=$'\013'
local SUPPRESS_SPACE=0
if compopt +o nospace 2> /dev/null; then
SUPPRESS_SPACE=1
fi
COMPREPLY=( $(IFS="$IFS" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
COMP_TYPE="$COMP_TYPE" \
_ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \
_ARGCOMPLETE=1 \
_ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \
__python_argcomplete_run "$1") )
if [[ $? != 0 ]]; then
unset COMPREPLY
elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then
compopt -o nospace
fi
}
complete -o nospace -o default -o bashdefault -F _python_argcomplete reframe
17 changes: 17 additions & 0 deletions etc/reframe_completion.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

function __fish_reframe_complete
set -x _ARGCOMPLETE 1
set -x _ARGCOMPLETE_DFS \t
set -x _ARGCOMPLETE_IFS \n
set -x _ARGCOMPLETE_SUPPRESS_SPACE 1
set -x _ARGCOMPLETE_SHELL fish
set -x COMP_LINE (commandline -p)
set -x COMP_POINT (string length (commandline -cp))
set -x COMP_TYPE
if set -q _ARC_DEBUG
reframe 8>&1 9>&2 1>/dev/null 2>&1
else
reframe 8>&1 9>&2 1>&9 2>&1
end
end
complete -c reframe -f -a '(__fish_reframe_complete)'
1 change: 1 addition & 0 deletions etc/reframe_completion.tcsh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
complete "reframe" 'p@*@`python-argcomplete-tcsh "reframe"`@' ;
4 changes: 4 additions & 0 deletions reframe/frontend/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause

import argcomplete
import argparse
import os

Expand Down Expand Up @@ -257,6 +258,9 @@ def parse_args(self, args=None, namespace=None):
`add_argument()` call. If no default value was specified either, the
attribute will be set to `None`.'''

# Enable auto-completion
argcomplete.autocomplete(self._holder)

# We always pass an empty namespace to our internal argparser and we do
# the namespace resolution ourselves. We do this, because we want the
# newly parsed options to completely override any options defined in
Expand Down
5 changes: 2 additions & 3 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,12 @@ def main():
help='Use a login shell for job scripts'
)

# Parse command line
options = argparser.parse_args()
if len(sys.argv) == 1:
argparser.print_help()
sys.exit(1)

# Parse command line
options = argparser.parse_args()

# First configure logging with our generic configuration so as to be able
# to print pretty messages; logging will be reconfigured by user's
# configuration later
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pytest-parallel==0.1.0
coverage==5.3
setuptools==50.3.0
wcwidth==0.2.5
argcomplete==1.12.2
#+pygelf%pygelf==0.3.6