<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def marvcli_query(ctx, list_tags, collections, discarded, outdated, path, tags, null):
 """Query datasets. Use --collection=* to list all datasets across all collections. """

    if not any([collections, discarded, list_tags, outdated, path, tags]):
        click.echo(ctx.get_help())
        ctx.exit(1)

    sep = '\x00' if null else '\n'

    site = create_app().site

    if '*' in collections:
        collections = None
    else:
        for col in collections:
            if col not in site.collections:
                ctx.fail('Unknown collection: {}'.format(col))

    if list_tags:
        tags = site.listtags(collections)
        if tags:
            click.echo(sep.join(tags), nl=not null)
        else:
            click.echo('no tags', err=True)
        return

    setids = site.query(collections, discarded, outdated, path, tags)
    if setids:
        sep = '\x00' if null else '\n'
        click.echo(sep.join(setids), nl=not null)