Coverage for birdplan/plugins/cmdline/ospf/interface/__init__.py: 86%
22 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
1#
2# SPDX-License-Identifier: GPL-3.0-or-later
3#
4# Copyright (c) 2019-2024, 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 OSPF interface."""
21import argparse
22from typing import Any, Dict
24from .....exceptions import BirdPlanErrorUsage
25from ...cmdline_plugin import BirdPlanCmdlinePluginBase
27__all__ = ["BirdPlanCmdlineOSPFInterface"]
30class BirdPlanCmdlineOSPFInterface(BirdPlanCmdlinePluginBase):
31 """BirdPlan "ospf interface" command."""
33 def __init__(self) -> None:
34 """Initialize object."""
36 super().__init__()
38 # Plugin setup
39 self.plugin_description = "birdplan ospf interface"
40 self.plugin_order = 20
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 plugins = args["plugins"]
55 parent_subparsers = plugins.call_plugin("birdplan.plugins.cmdline.ospf", "get_subparsers", {})
57 # CMD: ospf interface
58 subparser = parent_subparsers.add_parser("interface", help="OSPF interface commands")
59 subparser.add_argument(
60 "--action",
61 action="store_const",
62 const="ospf_interface",
63 default="ospf_interface",
64 help=argparse.SUPPRESS,
65 )
67 # Set our internal subparser property
68 self._subparser = subparser
69 self._subparsers = subparser.add_subparsers()
71 def cmd_ospf_interface(self, args: Any) -> Any: # pylint: disable=unused-argument
72 """
73 Commandline handler for "ospf interface" action.
75 Parameters
76 ----------
77 args : Dict[str, Any]
78 Method argument(s).
80 """
82 if not self._subparser:
83 raise RuntimeError()
85 raise BirdPlanErrorUsage("No options specified to 'ospf interface' action", self._subparser)