Skip to content

Commit 6b0d620

Browse files
authored
Merge pull request #392 from acharlieh/configurable_options
Break out search argument to option parsing for v2 custom search commands
2 parents da36226 + 8cea66f commit 6b0d620

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
@@ -646,6 +646,19 @@ def _process_protocol_v1(self, argv, ifile, ofile):
646646

647647
debug('%s.process finished under protocol_version=1', class_name)
648648

649+
def _protocol_v2_option_parser(self, arg):
650+
""" Determines if an argument is an Option/Value pair, or just a Positional Argument.
651+
Method so different search commands can handle parsing of arguments differently.
652+
653+
:param arg: A single argument provided to the command from SPL
654+
:type arg: str
655+
656+
:return: [OptionName, OptionValue] OR [PositionalArgument]
657+
:rtype: List[str]
658+
659+
"""
660+
return arg.split('=', 1)
661+
649662
def _process_protocol_v2(self, argv, ifile, ofile):
650663
""" Processes records on the `input stream optionally writing records to the output stream.
651664
@@ -716,7 +729,7 @@ def _process_protocol_v2(self, argv, ifile, ofile):
716729

717730
if args and type(args) == list:
718731
for arg in args:
719-
result = arg.split('=', 1)
732+
result = self._protocol_v2_option_parser(arg)
720733
if len(result) == 1:
721734
self.fieldnames.append(str(result[0]))
722735
else:

0 commit comments

Comments
 (0)