| 160 | |
| 161 | @lru_cache(maxsize=1) |
| 162 | def get_main_parser(): |
| 163 | parent_parser = get_parent_parser() |
| 164 | |
| 165 | # Main parser |
| 166 | desc = "Data Version Control" |
| 167 | parser = DvcParser( |
| 168 | prog="dvc", |
| 169 | description=desc, |
| 170 | parents=[parent_parser], |
| 171 | formatter_class=formatter.RawTextHelpFormatter, |
| 172 | add_help=False, |
| 173 | ) |
| 174 | |
| 175 | # NOTE: We are doing this to capitalize help message. |
| 176 | # Unfortunately, there is no easier and clearer way to do it, |
| 177 | # as adding this argument in get_parent_parser() either in |
| 178 | # log_level_group or on parent_parser itself will cause unexpected error. |
| 179 | parser.add_argument( |
| 180 | "-h", |
| 181 | "--help", |
| 182 | action="help", |
| 183 | default=argparse.SUPPRESS, |
| 184 | help="Show this help message and exit.", |
| 185 | ) |
| 186 | |
| 187 | parser.add_argument( |
| 188 | "-V", |
| 189 | "--version", |
| 190 | action="version", |
| 191 | version=__version__, |
| 192 | help="Show program's version.", |
| 193 | ) |
| 194 | |
| 195 | parser.add_argument( |
| 196 | "--cd", |
| 197 | default=os.path.curdir, |
| 198 | metavar="<path>", |
| 199 | help="Change to directory before executing.", |
| 200 | type=str, |
| 201 | ) |
| 202 | |
| 203 | parser.add_argument( |
| 204 | "--wait-for-lock", |
| 205 | action="store_true", |
| 206 | default=False, |
| 207 | help="Wait for the lock if it is already held by another process, instead of" |
| 208 | " failing immediately.", |
| 209 | ) |
| 210 | |
| 211 | # Sub commands |
| 212 | subparsers = parser.add_subparsers( |
| 213 | title="Available Commands", |
| 214 | metavar="command", |
| 215 | dest="cmd", |
| 216 | help="Use `dvc command --help` for command-specific help.", |
| 217 | required=True, |
| 218 | ) |
| 219 | |