Skip to content

Instantly share code, notes, and snippets.

@leetschau
Last active September 25, 2016 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leetschau/fa82513bff32efdfb2cb92a2bf0802df to your computer and use it in GitHub Desktop.
Save leetschau/fa82513bff32efdfb2cb92a2bf0802df to your computer and use it in GitHub Desktop.
import argparse
parser = argparse.ArgumentParser(
description='Sync docs in MongoDB to Elasticsearch server')
parser.add_argument('inputfile_name',
help='the json file contains data to synced from MongoDB')
parser.add_argument('-s', '--server-name',
help='the IP address of Elasticsearch server')
parser.add_argument('-i', '--index', help='the index name of ES')
parser.add_argument('-t', '--type-name', help='the type name of the index')
parser.add_argument('-e', '--exclude',
help='exclude list by the recurrence.timeStart field')
args = parser.parse_args()
base_url = 'http://%s:%s/%s/%s/' % (args.inputfile_name, args.server_name, args.index, args.type_name)
print(base_url)
@leetschau
Copy link
Author

leetschau commented Sep 25, 2016

  • using underscore (inputfile_name for example) in positional arguments
  • using dash (--server-name for example) in optional arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment