From 87135f5a14bc825037238a58f069965677cd058f Mon Sep 17 00:00:00 2001 From: jimmy-seraph1080 Date: Mon, 20 Oct 2025 03:08:49 -0400 Subject: [PATCH 1/3] add set up --- pyproject.toml | 18 ++++++++++++++++++ src/githelp/_init_.py | 2 ++ src/githelp/cli.py | 19 +++++++++++++++++++ src/githelp/greeter.py | 6 ++++++ 4 files changed, 45 insertions(+) create mode 100644 pyproject.toml create mode 100644 src/githelp/_init_.py create mode 100644 src/githelp/cli.py create mode 100644 src/githelp/greeter.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..522f6c4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +#how the project is built +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +#project's metadata +[project] +name = "githelp" +version = "0.1.0" +description = "example CLI using Click." +authors = [{ name = "Jimmy Zhang", email = "jimmy_zhang@uri.edu" }] +readme = "README.md" +requires-python = ">=3.9" +dependencies = ["click>=8.1"] + +# This creates the 'githelp' command +[project.scripts] +githelp = "githelp.cli:main" \ No newline at end of file diff --git a/src/githelp/_init_.py b/src/githelp/_init_.py new file mode 100644 index 0000000..469e977 --- /dev/null +++ b/src/githelp/_init_.py @@ -0,0 +1,2 @@ +__all__ = ["__version__"] +__version__ = "0.1.0" \ No newline at end of file diff --git a/src/githelp/cli.py b/src/githelp/cli.py new file mode 100644 index 0000000..7fb55dc --- /dev/null +++ b/src/githelp/cli.py @@ -0,0 +1,19 @@ +#import the click library for the building cli interfaces +import click +#import the inner function that actually builds the greeting text +#keynote ".greater" is a relative import not an absolute. +from .greeter import make_greeting + +#declare the click command +#the text in help show up in the githelp --help +@click.command(help="Say hello from githelp.") +#option "--name is define" and "-n" for short +#default= World if user didnt provide a name +#show default flag is set to false so it doesnt display in option +@click.option("--name", "-n", default="World", show_default=False, help="Who to greet.") +#here there is a boolean flag pair --shout/--no-shout" +@click.option("--shout/--no-shout", default=False, show_default=False, help="End with an exclamation mark.") +#click auto parse the value +def main(name: str, shout: bool) -> None: + # Call the inner function to build the message, then print it to stdout + click.echo(make_greeting(name, shout)) \ No newline at end of file diff --git a/src/githelp/greeter.py b/src/githelp/greeter.py new file mode 100644 index 0000000..d4a4321 --- /dev/null +++ b/src/githelp/greeter.py @@ -0,0 +1,6 @@ +def make_greeting(name, shout = False): + if(shout): + suffix = "!" + else: + suffix = "." + return f"Hello, {name}{suffix}" \ No newline at end of file From 4df0403502997c77e172b17568d6e56ee3a17609 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 20 Oct 2025 15:54:03 -0400 Subject: [PATCH 2/3] add setup --- pyproject.toml | 2 +- src/githelp/cli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 522f6c4..70d6a07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,6 @@ readme = "README.md" requires-python = ">=3.9" dependencies = ["click>=8.1"] -# This creates the 'githelp' command +#this creates the 'githelp' command [project.scripts] githelp = "githelp.cli:main" \ No newline at end of file diff --git a/src/githelp/cli.py b/src/githelp/cli.py index 7fb55dc..11c6c9c 100644 --- a/src/githelp/cli.py +++ b/src/githelp/cli.py @@ -15,5 +15,5 @@ @click.option("--shout/--no-shout", default=False, show_default=False, help="End with an exclamation mark.") #click auto parse the value def main(name: str, shout: bool) -> None: - # Call the inner function to build the message, then print it to stdout + #call the inner function to build the message, then print it to stdout click.echo(make_greeting(name, shout)) \ No newline at end of file From def2c4c3d94a515866d6ea2c35e91cfb2b572eb3 Mon Sep 17 00:00:00 2001 From: Jimmy Zhang <111541103+Jimmy-seraph1080@users.noreply.github.com> Date: Sat, 15 Nov 2025 20:54:26 +0000 Subject: [PATCH 3/3] change main and remove redundant comment --- poetry.lock | 34 ++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- src/githelp/cli.py | 9 +-------- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 poetry.lock diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..a901639 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,34 @@ +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. + +[[package]] +name = "click" +version = "8.1.8" +description = "Composable command line interface toolkit" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"}, + {file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main"] +markers = "platform_system == \"Windows\"" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.9" +content-hash = "a342985ec12de86e05e4472dc581164e609722e70b66e59628db724d2e046329" diff --git a/pyproject.toml b/pyproject.toml index 70d6a07..f8f9c60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,4 +15,4 @@ dependencies = ["click>=8.1"] #this creates the 'githelp' command [project.scripts] -githelp = "githelp.cli:main" \ No newline at end of file +githelp = "githelp.cli:githelp_cli" \ No newline at end of file diff --git a/src/githelp/cli.py b/src/githelp/cli.py index 11c6c9c..74afbeb 100644 --- a/src/githelp/cli.py +++ b/src/githelp/cli.py @@ -1,19 +1,12 @@ -#import the click library for the building cli interfaces import click -#import the inner function that actually builds the greeting text -#keynote ".greater" is a relative import not an absolute. from .greeter import make_greeting #declare the click command #the text in help show up in the githelp --help @click.command(help="Say hello from githelp.") -#option "--name is define" and "-n" for short -#default= World if user didnt provide a name -#show default flag is set to false so it doesnt display in option @click.option("--name", "-n", default="World", show_default=False, help="Who to greet.") #here there is a boolean flag pair --shout/--no-shout" @click.option("--shout/--no-shout", default=False, show_default=False, help="End with an exclamation mark.") #click auto parse the value -def main(name: str, shout: bool) -> None: - #call the inner function to build the message, then print it to stdout +def githelp_cli(name: str, shout: bool) -> None: click.echo(make_greeting(name, shout)) \ No newline at end of file