Skip to content

Predefined type for parsing files #67

Description

@joshua-light

As a CLI developer, I can use some predefined type to convert a CLI argument that represents a file path into the opened file handle.

API

test.py:

from mints import cli, Arg, File

@cli
def test(x: Arg[File]):
    print(x.text())

if __name__ == '__main__':
    cli()

1.txt:

Hello!

shell:

$ python test.py 1.txt
Hello!

Requirements

  • Add a new File type that is able to be constructed from a string.
  • Add text() method to the new type. (This would be similar to read().)
  • Add integration tests for the new type.
  • Add a new section to docs that will cover predefined types. Write about File here.

Notes

  • This is pretty similar to File type from Click.

Questions

  • Should we import predefined types from a separate module, e.g., from mints.types import File?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions