From b2f7a890eca26f4c248a632081714f971461dd7b Mon Sep 17 00:00:00 2001 From: BountyHunter Date: Sat, 13 Jun 2026 11:47:26 +0200 Subject: [PATCH] feat: add --json output mode --- git-context | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/git-context b/git-context index 92e2b81..1ec3dc4 100755 --- a/git-context +++ b/git-context @@ -9,6 +9,7 @@ Usage: git context [--depth N] [--files] [--log N] [--output file] [--dir 0 else None, + "branches": branches if branches else None, + "tree": tree_out, + } + if args.files: + out_dict["files"] = contents + output = json.dumps(out_dict, indent=2) + else: + output = "\n".join(sections) if args.output: - Path(args.output).write_text(output) + Path(args.output).write_text(output, encoding='utf-8') print(f"✅ Written to {args.output}") else: print(output)