Skip to content

Commit 8cea66f

Browse files
committed
Break out search argument parsing
This should be a passive change, while providing a useful extension point.
1 parent 2516a45 commit 8cea66f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

splunklib/searchcommands/search_command.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,19 @@ def _process_protocol_v1(self, argv, ifile, ofile):
634634

635635
debug('%s.process finished under protocol_version=1', class_name)
636636

637+
def _protocol_v2_option_parser(self, arg):
638+
""" Determines if an argument is an Option/Value pair, or just a Positional Argument.
639+
Method so different search commands can handle parsing of arguments differently.
640+
641+
:param arg: A single argument provided to the command from SPL
642+
:type arg: str
643+
644+
:return: [OptionName, OptionValue] OR [PositionalArgument]
645+
:rtype: List[str]
646+
647+
"""
648+
return arg.split('=', 1)
649+
637650
def _process_protocol_v2(self, argv, ifile, ofile):
638651
""" Processes records on the `input stream optionally writing records to the output stream.
639652
@@ -704,7 +717,7 @@ def _process_protocol_v2(self, argv, ifile, ofile):
704717

705718
if args and type(args) == list:
706719
for arg in args:
707-
result = arg.split('=', 1)
720+
result = self._protocol_v2_option_parser(arg)
708721
if len(result) == 1:
709722
self.fieldnames.append(str(result[0]))
710723
else:

0 commit comments

Comments
 (0)