Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.

Commit ac2ee23

Browse files
committed
T7758: allow repeated option --type in list_interfaces
1 parent 9285b34 commit ac2ee23

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/completion/list_interfaces/list_interfaces.ml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(*
22
*)
3-
let intf_type = ref ""
3+
let intf_types = ref []
44
let broadcast = ref false
55
let bridgeable = ref false
66
let bondable = ref false
77
let no_vlan = ref false
88

99
let args = [
10-
("--type", Arg.String (fun s -> intf_type := s), "List interfaces of specified type");
10+
("--type", Arg.String (fun s -> intf_types := (s :: !intf_types)), "List interfaces of specified type");
1111
("--broadcast", Arg.Unit (fun () -> broadcast := true), "List broadcast interfaces");
1212
("--bridgeable", Arg.Unit (fun () -> bridgeable := true), "List bridgeable interfaces");
1313
("--bondable", Arg.Unit (fun () -> bondable := true), "List bondable interfaces");
@@ -99,8 +99,7 @@ let filter_no_vlan s =
9999
false
100100
with Not_found -> true
101101

102-
let get_interfaces =
103-
let intf_type = !intf_type in
102+
let get_interfaces_by_type out intf_type =
104103
let fltr =
105104
if String.length(intf_type) > 0 then
106105
filter_from_type intf_type
@@ -124,10 +123,16 @@ let get_interfaces =
124123
if !no_vlan then List.filter filter_no_vlan res
125124
else res
126125
in
127-
let res = List.filter filter_section res in
128-
match fltr with
129-
| Some f -> List.filter f res
130-
| None -> res
126+
let add_out =
127+
let res = List.filter filter_section res in
128+
match fltr with
129+
| Some f -> List.filter f res
130+
| None -> res
131+
in List.append out add_out
132+
133+
let get_interfaces =
134+
let types = List.rev !intf_types in
135+
List.fold_left get_interfaces_by_type [] types
131136

132137
let () =
133138
let res = get_interfaces in

0 commit comments

Comments
 (0)