foxmath 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: foxmath
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Minimalist CLI for math & cryptography exploration 🦊
5
5
  Author-email: Abhrankan Chakrabarti <abhrankan@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "foxmath"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Minimalist CLI for math & cryptography exploration 🦊"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -112,17 +112,20 @@ def main():
112
112
  if cmd == "legendre" or args.command == "legendre":
113
113
  ls = legendre_symbol(args.a, args.p)
114
114
  result.update({"command": "legendre", "a": args.a, "p": args.p, "value": ls})
115
- print(f"Legendre ({args.a}/{args.p}) = {ls}")
115
+ if not json_output:
116
+ print(f"Legendre ({args.a}/{args.p}) = {ls}")
116
117
 
117
118
  elif cmd == "pi" or args.command == "pi":
118
119
  approx = catalan_pi_approx(args.terms)
119
120
  result.update({"command": "pi", "terms": args.terms, "approx": str(approx)})
120
- print(f"π {approx} ({args.terms} terms)")
121
+ if not json_output:
122
+ print(f"π ≈ {approx} ({args.terms} terms)")
121
123
 
122
124
  elif cmd == "ecadd" or args.command == "ecadd":
123
125
  x3, y3 = ec_point_add(args.x1, args.y1, args.x2, args.y2, args.a, args.p)
124
126
  result.update({"command": "ecadd", "result": (x3, y3)})
125
- print(f"Result point: ({x3}, {y3})")
127
+ if not json_output:
128
+ print(f"Result point: ({x3}, {y3})")
126
129
 
127
130
  except Exception as e:
128
131
  print(f"Error: {e}", file=sys.stderr)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: foxmath
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Minimalist CLI for math & cryptography exploration 🦊
5
5
  Author-email: Abhrankan Chakrabarti <abhrankan@gmail.com>
6
6
  License: MIT
@@ -38,6 +38,15 @@ class TestJsonFlag(unittest.TestCase):
38
38
  self.assertEqual(code, 0)
39
39
  self.assertNotIn("{", out)
40
40
 
41
+ def test_json_output_is_pure_json_no_preamble(self):
42
+ # Regression check: --json used to still print the human-readable
43
+ # line first, breaking anything piping stdout into a JSON parser.
44
+ code, out, err = run("pi", "--terms", "20", "--json")
45
+ self.assertEqual(code, 0)
46
+ import json
47
+ parsed = json.loads(out) # raises if there's any leading text
48
+ self.assertEqual(parsed["command"], "pi")
49
+
41
50
 
42
51
  class TestSymlinkInvocation(unittest.TestCase):
43
52
  def setUp(self):
File without changes
File without changes
File without changes
File without changes
File without changes