Coverage for src/birdplan/plugins/cmdline/bgp/__init__.py: 85%
20 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-25 07:38 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-25 07:38 +0000
1#
2# SPDX-License-Identifier: GPL-3.0-or-later
3#
4# Copyright (c) 2019-2025, AllWorldIT
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
19"""BirdPlan commandline options for BGP."""
21import argparse
22from typing import Any
24from ....exceptions import BirdPlanUsageError
25from ..cmdline_plugin import BirdPlanCmdlinePluginBase
27__all__ = ["BirdPlanCmdlineBGP"]
30class BirdPlanCmdlineBGP(BirdPlanCmdlinePluginBase):
31 """BirdPlan "bgp" command."""
33 def __init__(self) -> None:
34 """Initialize object."""
36 super().__init__()
38 # Plugin setup
39 self.plugin_description = "birdplan bgp"
40 self.plugin_order = 10
42 def register_parsers(self, args: dict[str, Any]) -> None:
43 """
44 Register commandline parsers.
46 Parameters
47 ----------
48 args : Dict[str, Any]
49 Method argument(s).
51 """
53 root_parser = args["root_parser"]
55 subparser = root_parser.add_parser("bgp", help="BGP commands")
57 subparser.add_argument(
58 "--action",
59 action="store_const",
60 const="bgp",
61 default="bgp",
62 help=argparse.SUPPRESS,
63 )
65 # Set our internal subparser properties
66 self._subparser = subparser
67 self._subparsers = subparser.add_subparsers()
69 def cmd_bgp(self, args: dict[str, Any]) -> None: # noqa: ARG002
70 """
71 Commandline handler for "bgp" action.
73 Parameters
74 ----------
75 args : Dict[str, Any]
76 Method argument(s).
78 """
80 if not self._subparser:
81 raise RuntimeError
83 raise BirdPlanUsageError("No options specified to 'bgp' action", self._subparser)