"""
def __init__(self, file_=None, ini_section='alembic', output_buffer=None,
- stdout=sys.stdout):
+ stdout=sys.stdout, cmd_opts=None):
"""Construct a new :class:`.Config`
"""
self.config_ini_section = ini_section
self.output_buffer = output_buffer
self.stdout = stdout
+ self.cmd_opts = cmd_opts
+
+ cmd_opts = None
+ """The command-line options passed to the ``alembic`` script.
+
+ ..versionadded:: 0.6.0
+
+ """
config_file_name = None
"""Filesystem path to the .ini file in use."""
default="alembic",
help="Name of section in .ini file to "
"use for Alembic config")
+ parser.add_argument("-x", action="append",
+ help="Additional arguments consumed by "
+ "custom env.py scripts, e.g. -x "
+ "setting1=somesetting -x setting2=somesetting")
+
subparsers = parser.add_subparsers()
for fn in [getattr(command, n) for n in dir(command)]:
# behavior changed incompatibly in py3.3
self.parser.error("too few arguments")
else:
- cfg = Config(options.config, options.name)
+ cfg = Config(file_=options.config,
+ ini_section=options.name, cmd_opts=options)
self.run_cmd(cfg, options)
def main(argv=None, prog=None, **kwargs):
"""The console runner function for Alembic."""
CommandLine(prog=prog).main(argv=argv)
+
+if __name__ == '__main__':
+ main()
\ No newline at end of file
.. changelog::
:version: 0.6.0
+ .. change::
+ :tags: feature
+
+ Added :attr:`alembic.config.Config.cmd_opts` attribute,
+ allows access to the `argparse` options passed to the
+ `alembic` runner.
+
+ .. change::
+ :tags: feature
+
+ Added new command line argument ``-x``, allows extra arguments
+ to be appended to the command line which can be consumed
+ within an ``env.py`` script by looking at
+ ``context.config.cmd_opts.x``.
+
.. change::
:tags: bug
:tickets: 125