File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 33import json
44import sys
55
6-
6+ # Spec that defines the plugin's capabilities
77plugin = {
88 "name" : "Calculator" ,
99 "directives" : [
1919}
2020
2121
22+ # Helper to publish result to stdout as JSON
2223def 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
3436def 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 ()
You can’t perform that action at this time.
0 commit comments