Skip to content

Commit

Permalink
[jjo] address juju#5057 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjo committed Jun 28, 2016
1 parent 1e1438a commit 0d57b6d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions etc/bash_completion.d/juju-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _juju_2_0_machines_from_status() {
${_juju_cmd_PYTHON?} -c '
import json, sys
sys.stderr.close()
j=json.load(sys.stdin)
j = json.load(sys.stdin)
print ("\n".join(j.get("machines", {}).keys()));
' < ${cache_fname}
}
Expand All @@ -37,12 +37,12 @@ _juju_2_0_units_from_status() {
local cache_fname=$(_juju_2_0_juju_status_cache_fname)
[ -n "${cache_fname}" ] || return 0
${_juju_cmd_PYTHON?} -c '
trail="'${2}'"
trail = "'${2}'"
import json, sys
sys.stderr.close()
j=json.load(sys.stdin)
all_units=[]
for k,v in j.get("applications", {}).items():
j = json.load(sys.stdin)
all_units = []
for k, v in j.get("applications", {}).items():
if v.get("units"):
all_units.extend(v["units"].keys())
print ("\n".join([unit + trail for unit in all_units]))
Expand All @@ -56,7 +56,7 @@ _juju_2_0_applications_from_status() {
${_juju_cmd_PYTHON?} -c '
import json, sys
sys.stderr.close()
j=json.load(sys.stdin)
j = json.load(sys.stdin)
print ("\n".join(j.get("applications", {}).keys()))
' < ${cache_fname}
}
Expand Down Expand Up @@ -120,15 +120,17 @@ _juju_2_0_flags_for() {
_juju_2_0_list_controllers_from_stdin() {
sed '1s/^$/{}/' |\
${_juju_cmd_PYTHON?} -c '
import json, sys; sys.stderr.close();
import json, sys
sys.stderr.close()
print ("\n".join(
json.load(sys.stdin).get("controllers", {}).keys())
)'
}
_juju_2_0_list_models_from_stdin() {
sed '1s/^$/{}/' |\
${_juju_cmd_PYTHON?} -c '
import json, sys; sys.stderr.close()
import json, sys
sys.stderr.close()
print ("\n".join(
["'$1'" + m["name"] for m in json.load(sys.stdin).get("models", {})]
))'
Expand Down

0 comments on commit 0d57b6d

Please sign in to comment.