From fa19c654c354fc218883e68e242ec1fc45be1a51 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 21 Mar 2021 01:12:59 +0100 Subject: [PATCH] Update README CLI's options list and fix indentation issues for --help --- README.md | 5 ++ jupyterhub_idle_culler/__init__.py | 73 ++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9fe6696..46910bd 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,9 @@ The command line interface also gives a quick overview of the different options --cull-users Cull users in addition to servers. This is for use in temporary-user cases such as tmpnb. (default False) + --internal-certs-location The location of generated internal-ssl + certificates (only needed if + ssl_enabled=True) (default internal-ssl) --max-age The maximum age (in seconds) of servers that should be culled even if they are active (default 0) @@ -78,6 +81,8 @@ The command line interface also gives a quick overview of the different options them. This is useful for a BinderHub that uses authentication and named servers. (default False) + --ssl-enabled Whether the Jupyter API endpoint has TLS + enabled (default False) --timeout The idle timeout (in seconds) (default 600) --url The JupyterHub API URL ``` diff --git a/jupyterhub_idle_culler/__init__.py b/jupyterhub_idle_culler/__init__.py index 252f18e..1360b93 100755 --- a/jupyterhub_idle_culler/__init__.py +++ b/jupyterhub_idle_culler/__init__.py @@ -10,6 +10,7 @@ from datetime import timezone from distutils.version import LooseVersion as V from functools import partial +from textwrap import dedent try: from urllib.parse import quote @@ -381,56 +382,98 @@ def main(): define( "url", default=os.environ.get("JUPYTERHUB_API_URL"), - help="The JupyterHub API URL", + help=dedent( + """ + The JupyterHub API URL. + """ + ).strip(), + ) + define( + "timeout", + type=int, + default=600, + help=dedent( + """ + The idle timeout (in seconds). + """ + ).strip(), ) - define("timeout", type=int, default=600, help="The idle timeout (in seconds)") define( "cull_every", type=int, default=0, - help="The interval (in seconds) for checking for idle servers to cull", + help=dedent( + """ + The interval (in seconds) for checking for idle servers to cull. + """ + ).strip(), ) define( "max_age", type=int, default=0, - help="The maximum age (in seconds) of servers that should be culled even if they are active", + help=dedent( + """ + The maximum age (in seconds) of servers that should be culled even if they are active. + """ + ).strip(), ) define( "cull_users", type=bool, default=False, - help="""Cull users in addition to servers. - This is for use in temporary-user cases such as tmpnb.""", + help=dedent( + """ + Cull users in addition to servers. + + This is for use in temporary-user cases such as tmpnb. + """ + ).strip(), ) define( "remove_named_servers", default=False, type=bool, - help="""Remove named servers in addition to stopping them. - This is useful for a BinderHub that uses authentication and named servers.""", + help=dedent( + """ + Remove named servers in addition to stopping them. + + This is useful for a BinderHub that uses authentication and named servers. + """ + ).strip(), ) define( "concurrency", type=int, default=10, - help="""Limit the number of concurrent requests made to the Hub. - - Deleting a lot of users at the same time can slow down the Hub, - so limit the number of API requests we have outstanding at any given time. - """, + help=dedent( + """ + Limit the number of concurrent requests made to the Hub. + + Deleting a lot of users at the same time can slow down the Hub, + so limit the number of API requests we have outstanding at any given time. + """ + ).strip(), ) define( "ssl_enabled", type=bool, default=False, - help="Whether the Jupyter API endpoint has TLS enabled", + help=dedent( + """ + Whether the Jupyter API endpoint has TLS enabled. + """ + ).strip(), ) define( "internal_certs_location", type=str, default="internal-ssl", - help="The location of generated internal-ssl certificates (only needed if ssl_enabled=True)", + help=dedent( + """ + The location of generated internal-ssl certificates (only needed with --ssl-enabled=true). + """ + ).strip(), ) parse_command_line()