Create and return the ``ArgumentParser`` which will be used to parse the arguments to this command.
(self, prog_name, subcommand, **kwargs)
| 302 | return django.get_version() |
| 303 | |
| 304 | def create_parser(self, prog_name, subcommand, **kwargs): |
| 305 | """ |
| 306 | Create and return the ``ArgumentParser`` which will be used to |
| 307 | parse the arguments to this command. |
| 308 | """ |
| 309 | kwargs.setdefault("formatter_class", DjangoHelpFormatter) |
| 310 | parser = CommandParser( |
| 311 | prog="%s %s" % (os.path.basename(prog_name), subcommand), |
| 312 | description=self.help or None, |
| 313 | missing_args_message=getattr(self, "missing_args_message", None), |
| 314 | called_from_command_line=getattr(self, "_called_from_command_line", None), |
| 315 | **kwargs, |
| 316 | ) |
| 317 | self.add_base_argument( |
| 318 | parser, |
| 319 | "--version", |
| 320 | action="version", |
| 321 | version=self.get_version(), |
| 322 | help="Show program's version number and exit.", |
| 323 | ) |
| 324 | self.add_base_argument( |
| 325 | parser, |
| 326 | "-v", |
| 327 | "--verbosity", |
| 328 | default=1, |
| 329 | type=int, |
| 330 | choices=[0, 1, 2, 3], |
| 331 | help=( |
| 332 | "Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, " |
| 333 | "3=very verbose output" |
| 334 | ), |
| 335 | ) |
| 336 | self.add_base_argument( |
| 337 | parser, |
| 338 | "--settings", |
| 339 | help=( |
| 340 | "The Python path to a settings module, e.g. " |
| 341 | '"myproject.settings.main". If this isn\'t provided, the ' |
| 342 | "DJANGO_SETTINGS_MODULE environment variable will be used." |
| 343 | ), |
| 344 | ) |
| 345 | self.add_base_argument( |
| 346 | parser, |
| 347 | "--pythonpath", |
| 348 | help=( |
| 349 | "A directory to add to the Python path, e.g. " |
| 350 | '"/home/djangoprojects/myproject".' |
| 351 | ), |
| 352 | ) |
| 353 | self.add_base_argument( |
| 354 | parser, |
| 355 | "--traceback", |
| 356 | action="store_true", |
| 357 | help="Display a full stack trace on CommandError exceptions.", |
| 358 | ) |
| 359 | self.add_base_argument( |
| 360 | parser, |
| 361 | "--no-color", |