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:
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?
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:1.txt:shell:Requirements
Filetype that is able to be constructed from a string.text()method to the new type. (This would be similar toread().)Filehere.Notes
Filetype from Click.Questions
from mints.types import File?