Skip to content

Commit 5c7dcf9

Browse files
committed
wip: improve readability
1 parent 1e52823 commit 5c7dcf9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plugin.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import sys
55

6-
6+
# Spec that defines the plugin's capabilities
77
plugin = {
88
"name": "Calculator",
99
"directives": [
@@ -19,6 +19,7 @@
1919
}
2020

2121

22+
# Helper to publish result to stdout as JSON
2223
def declare_result(content):
2324
"""Declare result as JSON to stdout
2425
@@ -31,6 +32,7 @@ def declare_result(content):
3132
raise SystemExit(0)
3233

3334

35+
# Execute a directive
3436
def run_directive(name, data):
3537
"""Execute a directive with the given name and data
3638
@@ -45,13 +47,13 @@ def run_directive(name, data):
4547
return [result]
4648

4749

48-
if __name__ == "__main__":
50+
def main(argv=None):
4951
parser = argparse.ArgumentParser()
5052
group = parser.add_mutually_exclusive_group()
5153
group.add_argument("--role")
5254
group.add_argument("--directive")
5355
group.add_argument("--transform")
54-
args = parser.parse_args()
56+
args = parser.parse_args(argv)
5557

5658
if args.directive:
5759
data = json.load(sys.stdin)
@@ -62,3 +64,7 @@ def run_directive(name, data):
6264
raise NotImplementedError
6365
else:
6466
declare_result(plugin)
67+
68+
69+
if __name__ == "__main__":
70+
main()

0 commit comments

Comments
 (0)