|
5 | 5 | from .common_parser import get_common_args |
6 | 6 |
|
7 | 7 |
|
| 8 | +class StoredTrue(argparse.Action): |
| 9 | + |
| 10 | + _value = True |
| 11 | + |
| 12 | + def __init__(self, option_strings, dest, nargs = 0, **kwargs): |
| 13 | + super().__init__(option_strings, dest, nargs=nargs, **kwargs) |
| 14 | + |
| 15 | + def __call__(self, parser, namespace, values, option_string=None): |
| 16 | + setattr(namespace, self.dest + '_set', True) |
| 17 | + setattr(namespace, self.dest, self._value) |
| 18 | + |
| 19 | + |
| 20 | +class StoredFalse(StoredTrue): |
| 21 | + |
| 22 | + _value = False |
| 23 | + |
| 24 | + |
8 | 25 | def parser(): |
9 | 26 | """construct the parser object""" |
10 | 27 | common_arguments = get_common_args(log_file=True) |
@@ -106,32 +123,32 @@ def parser(): |
106 | 123 | for command_parser in [update_command_parser, install_command_parser]: |
107 | 124 | command_parser.add_argument( |
108 | 125 | "--skip_install_tool_dependencies", |
109 | | - action="store_false", |
| 126 | + action=StoredFalse, |
110 | 127 | dest="install_tool_dependencies", |
111 | 128 | default=False, # Override True default for this function |
112 | 129 | help=argparse.SUPPRESS) # Deprecated function. Leave for backwards compatibility. |
113 | 130 | command_parser.add_argument( |
114 | 131 | "--install_tool_dependencies", |
115 | | - action="store_true", |
| 132 | + action=StoredTrue, |
116 | 133 | dest="install_tool_dependencies", |
117 | 134 | help="Turn on installation of tool dependencies using classic toolshed packages. " |
118 | 135 | "Can be overwritten on a per-tool basis in the tools file.") |
119 | 136 | command_parser.add_argument( |
120 | 137 | "--install_resolver_dependencies", |
121 | | - action="store_true", |
| 138 | + action=StoredTrue, |
122 | 139 | dest="install_resolver_dependencies", |
123 | 140 | default=True, # Override False default for this function |
124 | 141 | help=argparse.SUPPRESS) # Deprecated function. Leave for backwards compatibility. |
125 | 142 | command_parser.add_argument( |
126 | 143 | "--skip_install_resolver_dependencies", |
127 | | - action="store_false", |
| 144 | + action=StoredFalse, |
128 | 145 | dest="install_resolver_dependencies", |
129 | 146 | help="Skip installing tool dependencies through resolver (e.g. conda). " |
130 | 147 | "Will be ignored on galaxy releases older than 16.07. " |
131 | 148 | "Can be overwritten on a per-tool basis in the tools file") |
132 | 149 | command_parser.add_argument( |
133 | 150 | "--skip_install_repository_dependencies", |
134 | | - action="store_false", |
| 151 | + action=StoredFalse, |
135 | 152 | dest="install_repository_dependencies", |
136 | 153 | help="Skip installing the repository dependencies." |
137 | 154 | ) |
|
0 commit comments