Coverage for pyTooling/CLIAbstraction/ValuedTupleFlag.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-22 21:29 +0000

1# ==================================================================================================================== # 

2# _____ _ _ ____ _ ___ _ _ _ _ _ # 

3# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / ___| | |_ _| / \ | |__ ___| |_ _ __ __ _ ___| |_(_) ___ _ __ # 

4# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` || | | | | | / _ \ | '_ \/ __| __| '__/ _` |/ __| __| |/ _ \| '_ \ # 

5# | |_) | |_| || | (_) | (_) | | | | | | (_| || |___| |___ | | / ___ \| |_) \__ \ |_| | | (_| | (__| |_| | (_) | | | | # 

6# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)____|_____|___/_/ \_\_.__/|___/\__|_| \__,_|\___|\__|_|\___/|_| |_| # 

7# |_| |___/ |___/ # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2017-2026 Patrick Lehmann - Bötzingen, Germany # 

15# Copyright 2014-2016 Technische Universität Dresden - Germany, Chair of VLSI-Design, Diagnostics and Architecture # 

16# # 

17# Licensed under the Apache License, Version 2.0 (the "License"); # 

18# you may not use this file except in compliance with the License. # 

19# You may obtain a copy of the License at # 

20# # 

21# http://www.apache.org/licenses/LICENSE-2.0 # 

22# # 

23# Unless required by applicable law or agreed to in writing, software # 

24# distributed under the License is distributed on an "AS IS" BASIS, # 

25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

26# See the License for the specific language governing permissions and # 

27# limitations under the License. # 

28# # 

29# SPDX-License-Identifier: Apache-2.0 # 

30# ==================================================================================================================== # 

31# 

32""" 

33Valued tuple-flag arguments represent a name and a value as a 2-tuple. 

34 

35.. seealso:: 

36 

37 :mod:`~pyTooling.CLIAbstraction.ValuedFlag` 

38 |rarr| For flags with a value. 

39 :class:`~pyTooling.CLIAbstraction.OptionalValuedFlag.OptionalValuedFlag` 

40 |rarr| For flags that have an optional value. 

41""" 

42from typing import Any 

43 

44from pyTooling.Decorators import export 

45from pyTooling.MetaClasses import abstractclass 

46from pyTooling.CLIAbstraction.Argument import NamedTupledArgument 

47 

48 

49@export 

50@abstractclass 

51class ShortTupleFlag(NamedTupledArgument[str], pattern="-{0}"): 

52 """ 

53 Represents a :class:`ValuedTupleArgument` with a single dash in front of the switch name. 

54 

55 **Example:** 

56 

57 * ``-file file1.txt`` 

58 """ 

59 def __init_subclass__(cls, *args: Any, pattern: str = "-{0}", **kwargs: Any) -> None: 

60 """ 

61 This method is called when a class is derived. 

62 

63 :param args: Any positional arguments. 

64 :param pattern: Optional, this pattern is used to format an argument. |br| 

65 Default: ``"-{0}"``. 

66 :param kwargs: Any keyword argument. 

67 """ 

68 kwargs["pattern"] = pattern 

69 super().__init_subclass__(*args, **kwargs) 

70 

71 

72@export 

73@abstractclass 

74class LongTupleFlag(NamedTupledArgument[str], pattern="--{0}"): 

75 """ 

76 Represents a :class:`ValuedTupleArgument` with a double dash in front of the switch name. 

77 

78 **Example:** 

79 

80 * ``--file file1.txt`` 

81 """ 

82 def __init_subclass__(cls, *args: Any, pattern: str = "--{0}", **kwargs: Any) -> None: 

83 """ 

84 This method is called when a class is derived. 

85 

86 :param args: Any positional arguments. 

87 :param pattern: Optional, this pattern is used to format an argument. |br| 

88 Default: ``"--{0}"``. 

89 :param kwargs: Any keyword argument. 

90 """ 

91 kwargs["pattern"] = pattern 

92 super().__init_subclass__(*args, **kwargs) 

93 

94 

95@export 

96@abstractclass 

97class WindowsTupleFlag(NamedTupledArgument[str], pattern="/{0}"): 

98 """ 

99 Represents a :class:`ValuedTupleArgument` with a single slash in front of the switch name. 

100 

101 **Example:** 

102 

103 * ``/file file1.txt`` 

104 """ 

105 def __init_subclass__(cls, *args: Any, pattern: str = "/{0}", **kwargs: Any) -> None: 

106 """ 

107 This method is called when a class is derived. 

108 

109 :param args: Any positional arguments. 

110 :param pattern: Optional, this pattern is used to format an argument. |br| 

111 Default: ``"/{0}"``. 

112 :param kwargs: Any keyword argument. 

113 """ 

114 kwargs["pattern"] = pattern 

115 super().__init_subclass__(*args, **kwargs)