From ea1557cdcd8923574980a67cfff26cef6a8b4edc Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Thu, 19 Jan 2023 09:26:53 +1030 Subject: [PATCH 1/6] Use click version option to get version --- .../{{cookiecutter.project_slug}}/__main__.py | 2 ++ .../{{cookiecutter.project_slug}}/util.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py index bd1afdb..83facfa 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py @@ -11,6 +11,7 @@ from .util import ( snake_base, print_version, + get_version, default_to_output, copy_config, run_snakemake, @@ -82,6 +83,7 @@ def common_options(func): @click.group( cls=OrderedCommands, context_settings=dict(help_option_names=["-h", "--help"]) ) +@click.version_option(get_version(), "-v", "--version", is_flag=True) def cli(): """For more options, run: {{cookiecutter.project_slug}} command --help""" diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py index 165cccc..09fb7e6 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py @@ -28,6 +28,12 @@ def print_version(): echo_click("\n" + "{{cookiecutter.project_name}} version " + version + "\n") +def get_version(): + with open(snake_base("{{cookiecutter.project_slug}}.VERSION"), "r") as f: + version = f.readline() + return version + + def echo_click(msg, log=None): click.echo(msg, nl=False, err=True) if log: From 36a33eb1f64bcb73fc73ebbdcae0154c4cb4183b Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Thu, 19 Jan 2023 09:27:37 +1030 Subject: [PATCH 2/6] Add README details to setup --- {{cookiecutter.project_slug}}/setup.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index 4ef6e15..e3b9d0f 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -11,6 +11,17 @@ def get_version(): ) ) as f: return f.readline().strip() + + +def get_description(): + with open("README.md", "r") as fh: + long_description = fh.read() + return long_description + + +def get_data_files(): + data_files = [(".", ["README.md"])] + return data_files CLASSIFIERS = [ @@ -33,9 +44,12 @@ def get_version(): url="{{cookiecutter.project_url}}", python_requires="{{cookiecutter.min_python_version}}", description="{{cookiecutter.project_description}}", + long_description=get_description(), + long_description_content_type="text/markdown", version=get_version(), author="{{cookiecutter.full_name}}", author_email="{{cookiecutter.email}}", + data_files=get_data_files(), py_modules=["{{cookiecutter.project_slug}}"], install_requires=[ "snakemake{{cookiecutter.snakemake_version}}", From a4cbf7cd837645da9680961815a3bd08be93a5d6 Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Thu, 19 Jan 2023 10:24:55 +1030 Subject: [PATCH 3/6] Update version options --- .../{{cookiecutter.project_slug}}/__main__.py | 1 - .../{{cookiecutter.project_slug}}/util.py | 6 ------ 2 files changed, 7 deletions(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py index 83facfa..312d73a 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py @@ -152,7 +152,6 @@ def citation(**kwargs): def main(): - print_version() cli() diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py index 09fb7e6..9cf4e7b 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/util.py @@ -22,12 +22,6 @@ def snake_base(rel_path): return os.path.join(os.path.dirname(os.path.realpath(__file__)), rel_path) -def print_version(): - with open(snake_base("{{cookiecutter.project_slug}}.VERSION"), "r") as f: - version = f.readline() - echo_click("\n" + "{{cookiecutter.project_name}} version " + version + "\n") - - def get_version(): with open(snake_base("{{cookiecutter.project_slug}}.VERSION"), "r") as f: version = f.readline() From 75dfdba625ab818e1ac74e281ebba62c3d07dc09 Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Thu, 19 Jan 2023 10:27:28 +1030 Subject: [PATCH 4/6] Update version options --- .../{{cookiecutter.project_slug}}/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py index 312d73a..e60d3cb 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py @@ -10,7 +10,6 @@ from .util import ( snake_base, - print_version, get_version, default_to_output, copy_config, From 255cdbe64e5214ae2d9617a355f4aeb1bf31ec3f Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Thu, 19 Jan 2023 10:33:14 +1030 Subject: [PATCH 5/6] Add project description to cli --- .../{{cookiecutter.project_slug}}/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py index e60d3cb..9a97966 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py @@ -84,7 +84,8 @@ def common_options(func): ) @click.version_option(get_version(), "-v", "--version", is_flag=True) def cli(): - """For more options, run: + """{{cookiecutter.project_description}}. + For more options, run: {{cookiecutter.project_slug}} command --help""" pass From 757dae93dae1e7e9d7856d22a8af4dfa815240c8 Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Thu, 19 Jan 2023 10:35:25 +1030 Subject: [PATCH 6/6] Update project description in cli --- .../{{cookiecutter.project_slug}}/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py index 9a97966..b0a41ff 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py @@ -84,7 +84,8 @@ def common_options(func): ) @click.version_option(get_version(), "-v", "--version", is_flag=True) def cli(): - """{{cookiecutter.project_description}}. + """{{cookiecutter.project_description}} + \b For more options, run: {{cookiecutter.project_slug}} command --help""" pass