Skip to content

Commit

Permalink
Fixed command line parsing, so that code which expects arguments in a…
Browse files Browse the repository at this point in the history
… peculiar order isn't confused by --conf=xxx.
  • Loading branch information
felixfontein committed Dec 28, 2014
1 parent e31f144 commit 51a24a8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions nikola/__main__.py
Expand Up @@ -68,6 +68,16 @@ def main(args=None):

if args is None:
args = sys.argv[1:]

conf_filename = 'conf.py'
conf_filename_changed = False
for index, arg in enumerate(args):
if arg[:7] == '--conf=':
del args[index]
conf_filename = arg[7:]
conf_filename_changed = True
break

quiet = False
if len(args) > 0 and args[0] == b'build' and b'--strict' in args:
LOGGER.notice('Running in strict mode')
Expand All @@ -78,13 +88,8 @@ def main(args=None):
quiet = True
global config

conf_filename = 'conf.py'
for index, arg in enumerate(args):
if arg[:7] == '--conf=':
conf_filename = arg[7:]
LOGGER.info("Using config file '{0}'".format(conf_filename))
del args[index]
break
if conf_filename_changed and not quiet:
LOGGER.info("Using config file '{0}'".format(conf_filename))

# Those commands do not require a `conf.py`. (Issue #1132)
# Moreover, actually having one somewhere in the tree can be bad, putting
Expand Down

0 comments on commit 51a24a8

Please sign in to comment.