<commit_before>import click

from panoptes_cli.scripts.panoptes import cli
from panoptes_client import Subject

@cli.group()
def subject():
    pass

@subject.command()
@click.option('--subject-set-id', type=int, required=False)
@click.option(
    '--quiet',
    '-q',
    is_flag=True,
    help='Only print subject IDs',
)
@click.argument('subject-id', type=int, required=False)
def ls(subject_set_id, quiet, subject_id):
    if subject_id:
        subject = Subject.find(subject_id)
        if quiet:
            click.echo(subject.id)
        else:
            echo_subject(subject)
        return

    subjects = Subject.where(subject_set_id=subject_set_id)
    if quiet:
        click.echo(" ".join([s.id for s in subjects]))
    else:
        for subject in subjects:
            echo_subject(subject)


def echo_subject(subject):
    click.echo(
        u'{} {}'.format(
            subject.id,
            ' '.join(map(lambda l: l.values()[0], subject.locations))
        )
    )
<commit_msg>Allow listing multiple subjects by ID<commit_after>import click

from panoptes_cli.scripts.panoptes import cli
from panoptes_client import Subject

@cli.group()
def subject():
    pass

@subject.command()
@click.option('--subject-set-id', type=int, required=False)
@click.option(
    '--quiet',
    '-q',
    is_flag=True,
    help='Only print subject IDs',
)
@click.argument('subject-ids', type=int, required=False, nargs=-1)
def ls(subject_set_id, quiet, subject_ids):
    if subject_ids:
        for subject_id in subject_ids:
            subject = Subject.find(subject_id)
            if quiet:
                click.echo(subject.id)
            else:
                echo_subject(subject)
        return

    subjects = Subject.where(subject_set_id=subject_set_id)
    if quiet:
        click.echo(" ".join([s.id for s in subjects]))
    else:
        for subject in subjects:
            echo_subject(subject)


def echo_subject(subject):
    click.echo(
        u'{} {}'.format(
            subject.id,
            ' '.join(map(lambda l: list(l.values())[0], subject.locations))
        )
    )

{'fraction_non_alphanumeric': 0.12749762131303521, 'fraction_numerical': 0.0014272121788772598, 'mean_word_length': 2.54040404040404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3808678', 'n_tokens_mistral': 671, 'n_tokens_neox': 658, 'n_words': 148}