desfr 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- desfr/__init__.py +0 -0
- desfr/cli.py +33 -0
- desfr-0.1.0.dist-info/METADATA +32 -0
- desfr-0.1.0.dist-info/RECORD +7 -0
- desfr-0.1.0.dist-info/WHEEL +5 -0
- desfr-0.1.0.dist-info/entry_points.txt +2 -0
- desfr-0.1.0.dist-info/top_level.txt +1 -0
desfr/__init__.py
ADDED
|
File without changes
|
desfr/cli.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
parser = argparse.ArgumentParser(
|
|
6
|
+
description="A dead simple file reader in CLI"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
10
|
+
|
|
11
|
+
read_parser = subparsers.add_parser("read", help="Read a text file")
|
|
12
|
+
read_parser.add_argument("filename")
|
|
13
|
+
|
|
14
|
+
args = parser.parse_args()
|
|
15
|
+
|
|
16
|
+
if args.command == "read":
|
|
17
|
+
file = Path(args.filename)
|
|
18
|
+
|
|
19
|
+
if file.suffix.lower() != ".txt":
|
|
20
|
+
parser.error("Error: Only text files are supported for now")
|
|
21
|
+
|
|
22
|
+
if not file.exists():
|
|
23
|
+
parser.error(f"Error: The File '{args.filename}' does not exist")
|
|
24
|
+
return
|
|
25
|
+
try:
|
|
26
|
+
content = file.read_text(encoding="utf-8")
|
|
27
|
+
|
|
28
|
+
print(content, end="")
|
|
29
|
+
except OSError as e:
|
|
30
|
+
parser.error(f"Cannot read file: {e}")
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
main()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: desfr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A dead simple CLI file reader
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# desfr
|
|
9
|
+
|
|
10
|
+
A dead simple command-line file reader.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install desfr
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Read a text file:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
desfr read filename.txt
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
You can also provide an absolute path:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
desfr read /path/to/filename.txt
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Currently supports `.txt` files.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
desfr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
desfr/cli.py,sha256=o1g8ZCpEe83NRTKJVo_AyS_nDY-ZygFO4JyHPH0sbUE,965
|
|
3
|
+
desfr-0.1.0.dist-info/METADATA,sha256=Z1IlypK45r_s3ruly4k8BJHjB3HFDfjNtGEjxg15Uao,467
|
|
4
|
+
desfr-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
desfr-0.1.0.dist-info/entry_points.txt,sha256=k0V0nxpg9ixfxSMTEqW3Db9oJs7ml2syGSICCrUBdxA,41
|
|
6
|
+
desfr-0.1.0.dist-info/top_level.txt,sha256=zH1J7B9kfjxY6huX32QpctlGcOPvYLPB-A17HvK0FT4,6
|
|
7
|
+
desfr-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
desfr
|