Merlijn van Deen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383401 )

Change subject: Extend webservice -h details
......................................................................

Extend webservice -h details

Adds a link to the online docs and a list of supported webservice types.
After this patch, `webservice -h` looks like this:

----------------------------------------------------------------------------
usage: webservice [-h] [--backend {gridengine,kubernetes}]
                  [type] {start,stop,status,restart,shell} [extra_args]

Online documentation: https://wikitech.wikimedia.org/wiki/Help:Toolforge/Web

Supported webservice types:
Kubernetes backend:  golang, jdk8, nodejs, php5.6 (default), python,
                     python2, ruby2, tcl
Grid Engine backend: generic, lighttpd (default), lighttpd-plain, nodejs,
                     tomcat, uwsgi-plain, uwsgi-python
---------------------------------------------------------------------------

with the further details below these lines.

Change-Id: Iba82fd4f884d9993ba50759ef150671c3ecf31cf
---
M scripts/webservice
1 file changed, 29 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/operations/software/tools-webservice 
refs/changes/01/383401/1

diff --git a/scripts/webservice b/scripts/webservice
index ae32246..8dba86a 100755
--- a/scripts/webservice
+++ b/scripts/webservice
@@ -2,6 +2,7 @@
 from __future__ import print_function
 import argparse
 import sys
+import textwrap
 
 from toollabs.webservice import WebService
 from toollabs.webservice.backends import Backend, GridEngineBackend, 
KubernetesBackend
@@ -10,7 +11,32 @@
 from toollabs.common.el import log_command_invocation
 
 
-argparser = argparse.ArgumentParser()
+GRIDENGINE_DEFAULT_TYPE = 'lighttpd'
+KUBERNETES_DEFAULT_TYPE = 'php5.6'
+
+
+def format_types_block(types, default):
+    types = sorted(t + " (default)" if t == default else t for t in types)
+    joined = ", ".join(types)
+    return textwrap.fill(joined, 55, subsequent_indent=' '*len('Grid Engine 
backend: '))
+
+
+description = """
+Online documentation: https://wikitech.wikimedia.org/wiki/Help:Toolforge/Web
+
+Supported webservice types:
+Kubernetes backend:  {kubernetes}
+Grid Engine backend: {gridengine}
+""".format(
+    kubernetes = format_types_block(KubernetesBackend.CONFIG.keys(), 
KUBERNETES_DEFAULT_TYPE),
+    gridengine = format_types_block(GridEngineBackend.CONFIG.keys(), 
GRIDENGINE_DEFAULT_TYPE)
+)
+
+argparser = argparse.ArgumentParser(
+    description=description,
+    formatter_class=argparse.RawDescriptionHelpFormatter
+)
+
 argparser.add_argument('type', help='Type of webservice to start',
                        nargs='?')
 argparser.add_argument('--backend', help='Which cluster backend to use run the 
webservice',
@@ -99,7 +125,7 @@
                 print("--release is deprecated and has no effect, using 
trusty...")
                 args.release = 'trusty'
         if args.type is None:
-            args.type = tool.manifest.get('web', 'lighttpd')
+            args.type = tool.manifest.get('web', GRIDENGINE_DEFAULT_TYPE)
         elif args.type == 'lighttpd-precise':
             print('*' * 78, file=sys.stderr)
             print(
@@ -115,7 +141,7 @@
             print("Please just pick an appropriate type instead")
             sys.exit(1)
         if args.type is None:
-            args.type = tool.manifest.get('web', 'php5.6')
+            args.type = tool.manifest.get('web', KUBERNETES_DEFAULT_TYPE)
         acceptable_types = KubernetesBackend.CONFIG.keys()
 
     if args.extra_args is None:

-- 
To view, visit https://gerrit.wikimedia.org/r/383401
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba82fd4f884d9993ba50759ef150671c3ecf31cf
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/tools-webservice
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhall...@arctus.nl>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to