From fa250e2ae3bafc3b124d5067be67a3972a5846be Mon Sep 17 00:00:00 2001 From: fluzzi Date: Tue, 5 Apr 2022 15:09:05 -0300 Subject: [PATCH] fix completion --- connpy/__init__.py | 2 +- connpy/connapp.py | 9 ++++++--- docs/connpy/index.html | 11 +++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/connpy/__init__.py b/connpy/__init__.py index ed28ed0..4b986d4 100644 --- a/connpy/__init__.py +++ b/connpy/__init__.py @@ -126,7 +126,7 @@ from .connapp import connapp from pkg_resources import get_distribution __all__ = ["node", "nodes", "configfile", "connapp"] -__version__ = "2.0.1" +__version__ = "2.0.2" __author__ = "Federico Luzzi" __pdoc__ = { 'core': False, diff --git a/connpy/connapp.py b/connpy/connapp.py index d2942f0..8cf2363 100755 --- a/connpy/connapp.py +++ b/connpy/connapp.py @@ -690,9 +690,11 @@ _conn() { DATADIR=$HOME/.config/conn + command -v jq >/dev/null 2>&1 && { mapfile -t connections < <(jq -r ' .["connections"] | paths as $path | select(getpath($path) == "connection") | $path | [map(select(. != "type"))[-1,-2,-3]] | map(select(. !=null)) | join("@")' $DATADIR/config.json) mapfile -t folders < <(jq -r ' .["connections"] | paths as $path | select(getpath($path) == "folder" or getpath($path) == "subfolder") | $path | [map(select(. != "type"))[-1,-2]] | map(select(. !=null)) | join("@")' $DATADIR/config.json) - mapfile -t profiles < <(jq -r '.["profiles"] | keys[]' $DATADIR/config.json) + mapfile -t profiles < <(jq -r '.["profiles"] | keys[]' $DATADIR/config.json) + } if [ "${#COMP_WORDS[@]}" = "2" ]; then strings="--add --del --rm --edit --mod --show mv move ls list cp copy profile bulk config --help" strings="$strings ${connections[@]} ${folders[@]/#/@}" @@ -733,7 +735,6 @@ _conn() } complete -o nosort -F _conn conn complete -o nosort -F _conn connpy - ''' if type == "zshcompletion": return ''' @@ -750,12 +751,14 @@ _conn() if [[ $words =~ '.* $' ]]; then num=$(($num + 1)) fi - x=`jq -r ' .["connections"] | paths as $path | select(getpath($path) == "connection") | $path | [map(select(. != "type"))[-1,-2,-3]] | map(select(. !=null)) | join("@")' /home/fluzzi32/.config/conn/config.json` + command -v jq >/dev/null 2>&1 && { + x=`jq -r ' .["connections"] | paths as $path | select(getpath($path) == "connection") | $path | [map(select(. != "type"))[-1,-2,-3]] | map(select(. !=null)) | join("@")' $DATADIR/config.json` connections=( $x ) x=`jq -r ' .["connections"] | paths as $path | select(getpath($path) == "folder" or getpath($path) == "subfolder") | $path | [map(select(. != "type"))[-1,-2]] | map(select(. !=null)) | join("@")' $DATADIR/config.json | sed -e 's/^/@/'` folders=( $x ) x=`jq -r '.["profiles"] | keys[]' $DATADIR/config.json` profiles=( $x ) + } if [ "${num}" = "2" ]; then strings="--add --del --rm --edit --mod --show mv move ls list cp copy profile bulk config --help" strings="$strings ${connections[@]} ${folders[@]}" diff --git a/docs/connpy/index.html b/docs/connpy/index.html index ec71a66..7586068 100644 --- a/docs/connpy/index.html +++ b/docs/connpy/index.html @@ -259,7 +259,7 @@ from .connapp import connapp from pkg_resources import get_distribution __all__ = ["node", "nodes", "configfile", "connapp"] -__version__ = "2.0.1" +__version__ = "2.0.2" __author__ = "Federico Luzzi" __pdoc__ = { 'core': False, @@ -1289,9 +1289,11 @@ _conn() { DATADIR=$HOME/.config/conn + command -v jq >/dev/null 2>&1 && { mapfile -t connections < <(jq -r ' .["connections"] | paths as $path | select(getpath($path) == "connection") | $path | [map(select(. != "type"))[-1,-2,-3]] | map(select(. !=null)) | join("@")' $DATADIR/config.json) mapfile -t folders < <(jq -r ' .["connections"] | paths as $path | select(getpath($path) == "folder" or getpath($path) == "subfolder") | $path | [map(select(. != "type"))[-1,-2]] | map(select(. !=null)) | join("@")' $DATADIR/config.json) - mapfile -t profiles < <(jq -r '.["profiles"] | keys[]' $DATADIR/config.json) + mapfile -t profiles < <(jq -r '.["profiles"] | keys[]' $DATADIR/config.json) + } if [ "${#COMP_WORDS[@]}" = "2" ]; then strings="--add --del --rm --edit --mod --show mv move ls list cp copy profile bulk config --help" strings="$strings ${connections[@]} ${folders[@]/#/@}" @@ -1332,7 +1334,6 @@ _conn() } complete -o nosort -F _conn conn complete -o nosort -F _conn connpy - ''' if type == "zshcompletion": return ''' @@ -1349,12 +1350,14 @@ _conn() if [[ $words =~ '.* $' ]]; then num=$(($num + 1)) fi - x=`jq -r ' .["connections"] | paths as $path | select(getpath($path) == "connection") | $path | [map(select(. != "type"))[-1,-2,-3]] | map(select(. !=null)) | join("@")' /home/fluzzi32/.config/conn/config.json` + command -v jq >/dev/null 2>&1 && { + x=`jq -r ' .["connections"] | paths as $path | select(getpath($path) == "connection") | $path | [map(select(. != "type"))[-1,-2,-3]] | map(select(. !=null)) | join("@")' $DATADIR/config.json` connections=( $x ) x=`jq -r ' .["connections"] | paths as $path | select(getpath($path) == "folder" or getpath($path) == "subfolder") | $path | [map(select(. != "type"))[-1,-2]] | map(select(. !=null)) | join("@")' $DATADIR/config.json | sed -e 's/^/@/'` folders=( $x ) x=`jq -r '.["profiles"] | keys[]' $DATADIR/config.json` profiles=( $x ) + } if [ "${num}" = "2" ]; then strings="--add --del --rm --edit --mod --show mv move ls list cp copy profile bulk config --help" strings="$strings ${connections[@]} ${folders[@]}"