diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-08-28 09:57:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-28 09:57:50 -0500 |
| commit | 51ac77cafa8ef8a649efa0bc8e05cd1f4f2a1ac6 (patch) | |
| tree | f36a039a8d2fdc05c1d2d27cf77ba954589bd9cd /src | |
| parent | b37afc1c422a56c6a3562fbc517d180ba059af8e (diff) | |
| parent | ac2ee231810b3d8718bc6dde76c21fff581ae1c2 (diff) | |
| download | vyos-1x-51ac77cafa8ef8a649efa0bc8e05cd1f4f2a1ac6.tar.gz vyos-1x-51ac77cafa8ef8a649efa0bc8e05cd1f4f2a1ac6.zip | |
Merge pull request #42 from jestabro/list-interfaces-multiple-types
T7758: allow repeated option --type in list_interfaces
Diffstat (limited to 'src')
| -rw-r--r-- | src/completion/list_interfaces/list_interfaces.ml | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/completion/list_interfaces/list_interfaces.ml b/src/completion/list_interfaces/list_interfaces.ml index f3db6bdfe..a8d5e7bed 100644 --- a/src/completion/list_interfaces/list_interfaces.ml +++ b/src/completion/list_interfaces/list_interfaces.ml @@ -1,13 +1,13 @@ (* *) -let intf_type = ref "" +let intf_types = ref [] let broadcast = ref false let bridgeable = ref false let bondable = ref false let no_vlan = ref false let args = [ - ("--type", Arg.String (fun s -> intf_type := s), "List interfaces of specified type"); + ("--type", Arg.String (fun s -> intf_types := (s :: !intf_types)), "List interfaces of specified type"); ("--broadcast", Arg.Unit (fun () -> broadcast := true), "List broadcast interfaces"); ("--bridgeable", Arg.Unit (fun () -> bridgeable := true), "List bridgeable interfaces"); ("--bondable", Arg.Unit (fun () -> bondable := true), "List bondable interfaces"); @@ -99,8 +99,7 @@ let filter_no_vlan s = false with Not_found -> true -let get_interfaces = - let intf_type = !intf_type in +let get_interfaces_by_type out intf_type = let fltr = if String.length(intf_type) > 0 then filter_from_type intf_type @@ -124,10 +123,16 @@ let get_interfaces = if !no_vlan then List.filter filter_no_vlan res else res in - let res = List.filter filter_section res in - match fltr with - | Some f -> List.filter f res - | None -> res + let add_out = + let res = List.filter filter_section res in + match fltr with + | Some f -> List.filter f res + | None -> res + in List.append out add_out + +let get_interfaces = + let types = List.rev !intf_types in + List.fold_left get_interfaces_by_type [] types let () = let res = get_interfaces in |
