diff --git a/github_to_sqlite/cli.py b/github_to_sqlite/cli.py index a335f2c..0194eda 100644 --- a/github_to_sqlite/cli.py +++ b/github_to_sqlite/cli.py @@ -465,28 +465,27 @@ def emojis(db_path, auth, fetch): def get(url, auth, paginate, nl): "Save repos owened by the specified (or authenticated) username or organization" token = load_token(auth) - if paginate or nl: - first = True - while url: - response = utils.get(url, token) - items = response.json() - if first and not nl: - click.echo("[") - for item in items: - if not first and not nl: - click.echo(",") - first = False - if not nl: - to_dump = json.dumps(item, indent=4) - click.echo(textwrap.indent(to_dump, " "), nl=False) - else: - click.echo(json.dumps(item)) - url = response.links.get("next", {}).get("url") - if not nl: - click.echo("\n]") - else: + first = True + while url: response = utils.get(url, token) - click.echo(json.dumps(response.json(), indent=4)) + items = response.json() + if first and not nl: + click.echo("[") + for item in items: + if not first and not nl: + click.echo(",") + first = False + if not nl: + to_dump = json.dumps(item, indent=4) + click.echo(textwrap.indent(to_dump, " "), nl=False) + else: + click.echo(json.dumps(item)) + if paginate: + url = response.links.get("next", {}).get("url") + else: + url = None + if not nl: + click.echo("\n]") def load_token(auth):