Skip to content

Commit 7382cd6

Browse files
committed
Fix 'default' group mapping and completions
1 parent 9395a1b commit 7382cd6

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

cmd/boring/tunnels.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ func controlTunnels(args []string, kind daemon.CmdKind) {
100100
var keep map[string]bool
101101

102102
if groupFilter != "" {
103-
keep = filterByGroup(ts, groupFilter)
103+
filterValue := groupFilter
104+
if groupFilter == "default" {
105+
filterValue = ""
106+
}
107+
keep = filterByGroup(ts, filterValue)
104108
if len(keep) == 0 {
105109
log.Fatalf("No %stunnels in group '%s'.", m, groupFilter)
106110
}
@@ -223,9 +227,13 @@ func listTunnels(args []string) {
223227

224228
// Filter by group if requested
225229
if groupFilter != "" {
230+
filterValue := groupFilter
231+
if groupFilter == "default" {
232+
filterValue = ""
233+
}
226234
var filtered []*tunnel.Desc
227235
for _, t := range all {
228-
if t.Group == groupFilter {
236+
if t.Group == filterValue {
229237
filtered = append(filtered, t)
230238
}
231239
}

completions/boring.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _boring() {
3636

3737
_boring_get_groups() {
3838
local -a groups
39-
groups=($(boring list 2>/dev/null | sed -n 's/^\[\(.*\)\]$/\1/p' | grep -v '^default$'))
39+
groups=($(boring list 2>/dev/null | sed -n 's/^\[\(.*\)\]$/\1/p'))
4040
COMPREPLY=($(compgen -W "${groups[*]}" -- "$cur"))
4141
}
4242

@@ -46,6 +46,8 @@ _boring() {
4646
cmd="${COMP_WORDS[1]}"
4747
if [[ "$prev" == "-g" || "$prev" == "--group" ]]; then
4848
_boring_get_groups
49+
elif [[ " ${COMP_WORDS[*]} " == *" -g "* || " ${COMP_WORDS[*]} " == *" --group "* ]]; then
50+
COMPREPLY=()
4951
elif [[ "$cmd" == "open" || "$cmd" == "o" ]]; then
5052
_boring_get_names "closed"
5153
elif [[ "$cmd" == "close" || "$cmd" == "c" ]]; then

completions/boring.fish

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function __boring_get_names
2626
end
2727

2828
function __boring_get_groups
29-
boring list 2>/dev/null | sed -n 's/^\[\(.*\)\]$/\1/p' | grep -v '^default$'
29+
boring list 2>/dev/null | sed -n 's/^\[\(.*\)\]$/\1/p'
3030
end
3131

3232
function __boring_complete
@@ -44,6 +44,9 @@ function __boring_complete
4444
__boring_get_groups
4545
return
4646
end
47+
if contains -- -g $arguments; or contains -- --group $arguments
48+
return
49+
end
4750

4851
switch $command
4952
case open o

completions/boring.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _boring() {
4141

4242
_boring_get_groups() {
4343
local -a groups
44-
groups=($(boring list 2>/dev/null | sed -n 's/^\[\(.*\)\]$/\1/p' | grep -v '^default$'))
44+
groups=($(boring list 2>/dev/null | sed -n 's/^\[\(.*\)\]$/\1/p'))
4545
if (( ${#groups[@]} )); then
4646
_values 'group' "${groups[@]}"
4747
fi
@@ -58,6 +58,8 @@ _boring() {
5858
names)
5959
if [[ "${words[CURRENT-1]}" == "-g" || "${words[CURRENT-1]}" == "--group" ]]; then
6060
_boring_get_groups
61+
elif (( ${line[(Ie)-g]} || ${line[(Ie)--group]} )); then
62+
return 1
6163
elif [[ $line[1] == "open" || $line[1] == "o" ]]; then
6264
_boring_get_names "closed" "${line[@]:1}"
6365
elif [[ $line[1] == "close" || $line[1] == "c" ]]; then

0 commit comments

Comments
 (0)