Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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:githelp_cli"
2 changes: 2 additions & 0 deletions src/githelp/_init_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = ["__version__"]
__version__ = "0.1.0"
12 changes: 12 additions & 0 deletions src/githelp/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import click
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.")
@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 githelp_cli(name: str, shout: bool) -> None:
click.echo(make_greeting(name, shout))
6 changes: 6 additions & 0 deletions src/githelp/greeter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def make_greeting(name, shout = False):
if(shout):
suffix = "!"
else:
suffix = "."
return f"Hello, {name}{suffix}"