From 259868e6fe83ce5d9e4e4ecb7feff42b2c6d60f8 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Thu, 15 Sep 2016 17:05:58 +0300 Subject: [PATCH] Adding a script for fast mistralclient help generation * This script allows generating helpstrings of all mistralclient commands and adopt them to rst format. * This script is just POC and requires a further manual editing in order to make the document more clear. Change-Id: If5f9144a254ef0b97c17e66638641e1052cc08d1 --- tools/generate_mistralclient_help.sh | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 tools/generate_mistralclient_help.sh diff --git a/tools/generate_mistralclient_help.sh b/tools/generate_mistralclient_help.sh new file mode 100755 index 000000000..c81c37305 --- /dev/null +++ b/tools/generate_mistralclient_help.sh @@ -0,0 +1,42 @@ +if [ -z "$1" ]; +then + echo + echo "Usage: $(basename $0) " + echo + exit +fi + +cmd_list=$(mistral --help | sed -e '1,/Commands for API/d' | cut -d " " -f 3 | grep -vwE "(help|complete|bash-completion)") + +file=$1 +> $file + +for cmd in $cmd_list +do + echo "Processing help for command $cmd..." + echo "**$cmd**:" >> $file + read -d '' helpstr << EOF + $(mistral help $cmd | sed -e '/output formatters/,$d' | grep -vwE "(--help)") +EOF + usage=$(echo "$helpstr" | sed -e '/^$/,$d' | sed 's/^/ /') + helpstr=$(echo "$helpstr" | sed -e '1,/^$/d') + echo -e "::\n" >> $file + echo "$usage" >> $file + echo >> $file + echo "$helpstr" >> $file + echo >> $file +done + + +# Delete empty 'optional arguments:'. +sed -i '/optional arguments:/ { +N +/^optional arguments:\n$/d +}' $file + +# Delete extra empty lines. +sed -i '/^$/ { +N +/^\n$/d +}' $file +