You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make nicer public interface to robot.utils.argumentparser.ArgFileParser #1876
One of the features I like a lot is the --argumentfile option. I would like to include an identical option in a tool I'm writing. So that my tool behaves consistently with robot it would be nice to be able to use the same parsing mechanism. Even though the parsing is very simple, there's no reason to duplicate code if I don't have to.
Right now, ArgFileParser appears to be a public class, though it's not importable via robot.utils -- I have to dig one more module down. So the first enhancement would be to let me import it with something like from robot.utils import ArgFileParser rather than from robot.utils.argumentparser import ArgFileParser.
The second enhancement would be to document it and clean up the interface. The constructor requires a list that I think needs to be ["-A", "--argumentfile"], but it's not clear why. Can that be made optional?
What I'd like is to be able to parse an argument file simply by doing:
from robot.utils import ArgFileParser
parser = ArgFileParser()
args = parser.process("/path/to/a/file")
The goal of this request is to try and introduce some commonality between robot and related tools. Admittedly, no other tools support argument files that I know of, but if robot exposed this functionality, perhaps more tools in the robotframework ecosystem would start to use it.
Can be done if you provide a pull request. If the class is made more public, I'd like its name to be changed to ArgumentFileParser, though.
Passing options to search for could be made optional. In that case you'd probably also want to rename _get_args to process_file or something similar. The current process takes the list of command line arguments, and replaces argument file option and path in it with arguments read from the file. I don't think that needs to be changed.
Activity
pekkaklarck commentedon Dec 12, 2014
Can be done if you provide a pull request. If the class is made more public, I'd like its name to be changed to
ArgumentFileParser, though.Passing options to search for could be made optional. In that case you'd probably also want to rename
_get_argstoprocess_fileor something similar. The currentprocesstakes the list of command line arguments, and replaces argument file option and path in it with arguments read from the file. I don't think that needs to be changed.pekkaklarck commentedon Jan 30, 2017
No comments since 2014. Closing.