Skip to content

Make nicer public interface to robot.utils.argumentparser.ArgFileParser #1876

Closed

Description

@boakley

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.

Activity

  1. pekkaklarck commented on Dec 12, 2014

    @pekkaklarck
    Member

    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.

  2. pekkaklarck commented on Jan 30, 2017

    @pekkaklarck
    Member

    No comments since 2014. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions