lipsum-cli 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.
lipsum_cli/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ from importlib.metadata import PackageNotFoundError, metadata, version
2
+
3
+ try:
4
+ __version__ = version("lipsum")
5
+ except PackageNotFoundError:
6
+ __version__ = "dev"
7
+
8
+ __all__ = ["__version__"]
9
+
10
+ pkg_name = __package__ or "lipsum"
11
+ meta = metadata(pkg_name)
lipsum_cli/cli.py ADDED
@@ -0,0 +1,88 @@
1
+ import argparse
2
+ from collections.abc import Sequence
3
+ from enum import StrEnum
4
+
5
+ import requests
6
+
7
+ from lipsum_cli import __version__, meta
8
+
9
+
10
+ class Unit(StrEnum):
11
+ PARAS = "paras"
12
+ WORDS = "words"
13
+ BYTES = "bytes"
14
+
15
+
16
+ class Options(argparse.Namespace):
17
+ version: bool
18
+ unit: Unit
19
+ amount: int
20
+ space: bool
21
+ no_lorem: bool
22
+
23
+
24
+ def main(argv: Sequence[str] | None = None) -> None:
25
+ parser = argparse.ArgumentParser(
26
+ prog=meta["Name"],
27
+ description=meta["Summary"],
28
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
29
+ )
30
+
31
+ parser.add_argument(
32
+ "-v",
33
+ "--version",
34
+ action="version",
35
+ version=f"%(prog)s {__version__}",
36
+ help="show program version",
37
+ )
38
+ parser.add_argument(
39
+ "-u",
40
+ "--unit",
41
+ type=Unit,
42
+ default=Unit.PARAS,
43
+ choices=[c.value for c in Unit],
44
+ help="units to generate",
45
+ )
46
+ parser.add_argument(
47
+ "-a", "--amount", type=int, required=True, help="amount of units to generate"
48
+ )
49
+ parser.add_argument(
50
+ "-s", "--space", action="store_true", default=False, help="space out paragraphs"
51
+ )
52
+ parser.add_argument(
53
+ "-n",
54
+ "--no-lorem",
55
+ action="store_true",
56
+ default=False,
57
+ help="do not begin with 'Lorem ipsum...'",
58
+ )
59
+
60
+ options = parser.parse_args(argv, namespace=Options())
61
+
62
+ print(get_text(options))
63
+
64
+
65
+ def get_text(options: Options) -> str:
66
+ url = f"https://lipsum.com/feed/json?{get_query_string(options)}"
67
+
68
+ res = requests.get(url)
69
+ json = res.json()
70
+
71
+ text: str = json["feed"]["lipsum"]
72
+
73
+ if options.space:
74
+ text = text.replace("\n", "\n\n")
75
+
76
+ return text
77
+
78
+
79
+ def get_query_string(options: Options) -> str:
80
+ return f"what={options.unit}&amount={options.amount}&start={yesno(not options.no_lorem)}"
81
+
82
+
83
+ def yesno(boolean: bool) -> str:
84
+ return "yes" if boolean else "no"
85
+
86
+
87
+ if __name__ == "__main__":
88
+ raise SystemExit(main())
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: lipsum-cli
3
+ Version: 0.1.0
4
+ Summary: Generate 'lorem ipsum' text from the lipsum.com API
5
+ Author: Jeff Pratt
6
+ Author-email: Jeff Pratt <clementi@noreply.codeberg.org>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: requests>=2.34.2
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+
@@ -0,0 +1,7 @@
1
+ lipsum_cli/__init__.py,sha256=OjIvvyhQNyjB9AnJh6rRXmbVpPDv6lEXqQQcBjs4Xvw,254
2
+ lipsum_cli/cli.py,sha256=2y0lWumMZztaeh-Hspcms6Z4ymTkLHZFCw5UJF2FTJI,1981
3
+ lipsum_cli-0.1.0.dist-info/licenses/LICENSE,sha256=m9i3vogyZqCuq6rZRrDtVWO8XeQCf2DqB57OT7xrj6c,1058
4
+ lipsum_cli-0.1.0.dist-info/WHEEL,sha256=G_-rrEibZr7OEM7zdH1dSO6s-VdjfnS5PA4CLAdI9Vw,80
5
+ lipsum_cli-0.1.0.dist-info/entry_points.txt,sha256=Cgq3qdhLuu_S9KY6Vo9YhMnot5SiukgtG7keZfImII8,48
6
+ lipsum_cli-0.1.0.dist-info/METADATA,sha256=gL7AyCOJ738h1G93vnGMHjcPgtJRl-MScJKxVmyEojU,334
7
+ lipsum_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.9
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ lipsum = lipsum_cli.cli:main
3
+
@@ -0,0 +1,7 @@
1
+ Copyright 2026 Jeff Pratt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.