66
77"""Tool to interact with the Pub/Sub interface and message queues"""
88
9- import sys
109import json
1110
1211import click
@@ -47,16 +46,16 @@ def unsubscribe(config, api, sub_id, secrets):
4746
4847
4948@kci_event .command (secrets = True )
49+ @click .argument ('input_file' , type = click .File ('r' ))
5050@click .option ('--is-json' , help = "Parse input data as JSON" , is_flag = True )
5151@Args .config
5252@Args .api
5353@click .argument ('channel' )
54- def send (config , api , is_json , channel , secrets ):
55- """Read some data on stdin and send it as an event on a channel"""
54+ # pylint: disable=too-many-arguments
55+ def send (input_file , is_json , config , api , channel , secrets ):
56+ """Read some data and send it as an event on a channel"""
5657 api = get_api (config , api , secrets )
57- data = sys .stdin .read ()
58- if is_json :
59- data = json .loads (data )
58+ data = json .load (input_file ) if is_json else input_file .read ()
6059 api .send_event (channel , {'data' : data })
6160
6261
@@ -78,16 +77,16 @@ def receive(config, api, indent, sub_id, secrets):
7877
7978
8079@kci_event .command (secrets = True )
80+ @click .argument ('input_file' , type = click .File ('r' ))
81+ @click .argument ('list_name' )
8182@click .option ('--is-json' , help = "Parse input data as JSON" , is_flag = True )
8283@Args .config
8384@Args .api
84- @ click . argument ( 'list_name' )
85- def push (config , api , is_json , list_name , secrets ):
86- """Read some data on stdin and push it as an event on a list"""
85+ # pylint: disable=too-many-arguments
86+ def push (input_file , list_name , is_json , config , api , secrets ):
87+ """Read some data and push it as an event on a list"""
8788 api = get_api (config , api , secrets )
88- data = sys .stdin .read ()
89- if is_json :
90- data = json .loads (data )
89+ data = json .load (input_file ) if is_json else input_file .read ()
9190 api .push_event (list_name , {'data' : data })
9291
9392
0 commit comments