Skip to content

Commit

Permalink
Inspect sys.argv for --projects with argparse before click
Browse files Browse the repository at this point in the history
  • Loading branch information
juhoinkinen committed Jun 18, 2019
1 parent ffc947f commit 2cf6b2a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions annif/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@
logger = annif.logger
click_log.basic_config(logger)


def set_project_config_path():
import argparse

# Instantiate the parser
parser = argparse.ArgumentParser(description='Optional app description')

# Optional positional argument
parser.add_argument('--projects', type=str, nargs='?',
help='An optional path to projects.cfg.')

args, _ = parser.parse_known_args()

print(sys.argv)
if args.projects:
sys.argv.remove('--projects')
sys.argv.remove(args.projects)
os.environ['ANNIF_PROJECTS'] = args.projects
print(sys.argv)


set_project_config_path()

cli = FlaskGroup(create_app=annif.create_app)


Expand Down

0 comments on commit 2cf6b2a

Please sign in to comment.