sample-hello-lib 0.1.0__tar.gz → 0.2.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sample-hello-lib
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A tiny sample PyPI library used to verify packaging and installation end-to-end.
5
5
  Project-URL: Homepage, https://pypi.org/project/sample-hello-lib/
6
6
  Author: glocky001
@@ -33,8 +33,9 @@ from sample_hello_lib import hello
33
33
  print(hello("world")) # Hello, world!
34
34
  ```
35
35
 
36
- Or from the command line:
36
+ Or from the command line — this opens a new console window (Windows) and
37
+ prints a `hello <username> <hostname>` greeting in it:
37
38
 
38
39
  ```bash
39
- sample-hello world
40
+ sample-hello
40
41
  ```
@@ -16,8 +16,9 @@ from sample_hello_lib import hello
16
16
  print(hello("world")) # Hello, world!
17
17
  ```
18
18
 
19
- Or from the command line:
19
+ Or from the command line — this opens a new console window (Windows) and
20
+ prints a `hello <username> <hostname>` greeting in it:
20
21
 
21
22
  ```bash
22
- sample-hello world
23
+ sample-hello
23
24
  ```
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sample-hello-lib"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "A tiny sample PyPI library used to verify packaging and installation end-to-end."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  """sample_hello_lib: a tiny sample library to verify PyPI packaging works end-to-end."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.0"
4
4
 
5
5
 
6
6
  def hello(name: str = "world") -> str:
@@ -0,0 +1,37 @@
1
+ """Command-line entry point for sample_hello_lib."""
2
+
3
+ import getpass
4
+ import socket
5
+ import subprocess
6
+ import sys
7
+
8
+
9
+ def greeting_message() -> str:
10
+ """Build the 'hello <username> <hostname>' greeting."""
11
+ return f"hello {getpass.getuser()} {socket.gethostname()}"
12
+
13
+
14
+ def open_new_console() -> int:
15
+ """Open a new console window and print the greeting in it.
16
+
17
+ Windows-only: spawns a fresh `cmd.exe` window via CREATE_NEW_CONSOLE.
18
+ On other platforms there's no portable equivalent, so the greeting is
19
+ printed in the current console instead.
20
+ """
21
+ message = greeting_message()
22
+ if sys.platform == "win32":
23
+ subprocess.Popen(
24
+ ["cmd", "/k", f"echo {message}"],
25
+ creationflags=subprocess.CREATE_NEW_CONSOLE,
26
+ )
27
+ else:
28
+ print(message)
29
+ return 0
30
+
31
+
32
+ def main() -> int:
33
+ return open_new_console()
34
+
35
+
36
+ if __name__ == "__main__":
37
+ raise SystemExit(main())
@@ -0,0 +1,22 @@
1
+ import getpass
2
+ import socket
3
+
4
+ from sample_hello_lib import __version__, hello
5
+ from sample_hello_lib.cli import greeting_message
6
+
7
+
8
+ def test_hello_default():
9
+ assert hello() == "Hello, world!"
10
+
11
+
12
+ def test_hello_name():
13
+ assert hello("pypi") == "Hello, pypi!"
14
+
15
+
16
+ def test_version_present():
17
+ assert isinstance(__version__, str) and __version__
18
+
19
+
20
+ def test_greeting_message():
21
+ expected = f"hello {getpass.getuser()} {socket.gethostname()}"
22
+ assert greeting_message() == expected
@@ -1,15 +0,0 @@
1
- """Command-line entry point for sample_hello_lib."""
2
-
3
- import sys
4
-
5
- from sample_hello_lib import hello
6
-
7
-
8
- def main() -> int:
9
- name = sys.argv[1] if len(sys.argv) > 1 else "world"
10
- print(hello(name))
11
- return 0
12
-
13
-
14
- if __name__ == "__main__":
15
- raise SystemExit(main())
@@ -1,13 +0,0 @@
1
- from sample_hello_lib import hello, __version__
2
-
3
-
4
- def test_hello_default():
5
- assert hello() == "Hello, world!"
6
-
7
-
8
- def test_hello_name():
9
- assert hello("pypi") == "Hello, pypi!"
10
-
11
-
12
- def test_version_present():
13
- assert isinstance(__version__, str) and __version__