def get_conn_vals(args):

    """
    Parses given arguments to then return  connection value string that can be
    used to connect to mongodb with.
    Args:
        args(obj): object returned by parser.parse_args()
    """

    vals_string = 'mongodb://'
    vals = {
        'host': args.host,
        'database': args.database
    }

    if args.user:
        vals['username'] = args.user
    if args.password:
        vals['password'] = args.password
    if args.port:
        vals['port'] = args.port

    if args.user and args.password:
        vals_string += '{user}:{password}@'

    vals_string += '{host}/{database}'

    if args.port:
        vals_string += ':{port}'

    return vals_string.format(**vals)