[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 66/72] scripts/qmp-shell: convert usage comment to docstring
From: |
John Snow |
Subject: |
[PULL 66/72] scripts/qmp-shell: convert usage comment to docstring |
Date: |
Fri, 18 Jun 2021 19:04:49 -0400 |
The nice usage comment should be a docstring instead of a comment, so
that it's visible from other python tooling.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-37-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qmp-shell | 128 ++++++++++++++++++++++++------------------
1 file changed, 72 insertions(+), 56 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index 8d5845ab48..82fe16cff8 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -1,7 +1,5 @@
#!/usr/bin/env python3
#
-# Low-level QEMU shell on top of QMP.
-#
# Copyright (C) 2009, 2010 Red Hat Inc.
#
# Authors:
@@ -10,60 +8,78 @@
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
#
-# Usage:
-#
-# Start QEMU with:
-#
-# # qemu [...] -qmp unix:./qmp-sock,server
-#
-# Run the shell:
-#
-# $ qmp-shell ./qmp-sock
-#
-# Commands have the following format:
-#
-# < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
-#
-# For example:
-#
-# (QEMU) device_add driver=e1000 id=net1
-# {u'return': {}}
-# (QEMU)
-#
-# key=value pairs also support Python or JSON object literal subset notations,
-# without spaces. Dictionaries/objects {} are supported as are arrays [].
-#
-# example-command arg-name1={'key':'value','obj'={'prop':"value"}}
-#
-# Both JSON and Python formatting should work, including both styles of
-# string literal quotes. Both paradigms of literal values should work,
-# including null/true/false for JSON and None/True/False for Python.
-#
-#
-# Transactions have the following multi-line format:
-#
-# transaction(
-# action-name1 [ arg-name1=arg1 ] ... [arg-nameN=argN ]
-# ...
-# action-nameN [ arg-name1=arg1 ] ... [arg-nameN=argN ]
-# )
-#
-# One line transactions are also supported:
-#
-# transaction( action-name1 ... )
-#
-# For example:
-#
-# (QEMU) transaction(
-# TRANS> block-dirty-bitmap-add node=drive0 name=bitmap1
-# TRANS> block-dirty-bitmap-clear node=drive0 name=bitmap0
-# TRANS> )
-# {"return": {}}
-# (QEMU)
-#
-# Use the -v and -p options to activate the verbose and pretty-print options,
-# which will echo back the properly formatted JSON-compliant QMP that is being
-# sent to QEMU, which is useful for debugging and documentation generation.
+
+"""
+Low-level QEMU shell on top of QMP.
+
+usage: qmp-shell [-h] [-H] [-N] [-v] [-p] qmp_server
+
+positional arguments:
+ qmp_server < UNIX socket path | TCP address:port >
+
+optional arguments:
+ -h, --help show this help message and exit
+ -H, --hmp Use HMP interface
+ -N, --skip-negotiation
+ Skip negotiate (for qemu-ga)
+ -v, --verbose Verbose (echo commands sent and received)
+ -p, --pretty Pretty-print JSON
+
+
+Start QEMU with:
+
+# qemu [...] -qmp unix:./qmp-sock,server
+
+Run the shell:
+
+$ qmp-shell ./qmp-sock
+
+Commands have the following format:
+
+ < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
+
+For example:
+
+(QEMU) device_add driver=e1000 id=net1
+{'return': {}}
+(QEMU)
+
+key=value pairs also support Python or JSON object literal subset notations,
+without spaces. Dictionaries/objects {} are supported as are arrays [].
+
+ example-command arg-name1={'key':'value','obj'={'prop':"value"}}
+
+Both JSON and Python formatting should work, including both styles of
+string literal quotes. Both paradigms of literal values should work,
+including null/true/false for JSON and None/True/False for Python.
+
+
+Transactions have the following multi-line format:
+
+ transaction(
+ action-name1 [ arg-name1=arg1 ] ... [arg-nameN=argN ]
+ ...
+ action-nameN [ arg-name1=arg1 ] ... [arg-nameN=argN ]
+ )
+
+One line transactions are also supported:
+
+ transaction( action-name1 ... )
+
+For example:
+
+ (QEMU) transaction(
+ TRANS> block-dirty-bitmap-add node=drive0 name=bitmap1
+ TRANS> block-dirty-bitmap-clear node=drive0 name=bitmap0
+ TRANS> )
+ {"return": {}}
+ (QEMU)
+
+Use the -v and -p options to activate the verbose and pretty-print options,
+which will echo back the properly formatted JSON-compliant QMP that is being
+sent to QEMU, which is useful for debugging and documentation generation.
+"""
+
import argparse
import ast
import json
--
2.31.1
- [PULL 47/72] scripts/qmp-shell: use argparse, (continued)
- [PULL 47/72] scripts/qmp-shell: use argparse, John Snow, 2021/06/18
- [PULL 45/72] scripts/qmp-shell: remove if-raise-else patterns, John Snow, 2021/06/18
- [PULL 55/72] scripts/qmp-shell: initialize completer early, John Snow, 2021/06/18
- [PULL 56/72] python/qmp: add QMPObject type alias, John Snow, 2021/06/18
- [PULL 57/72] scripts/qmp-shell: add mypy types, John Snow, 2021/06/18
- [PULL 59/72] scripts/qmp-shell: unprivatize 'pretty' property, John Snow, 2021/06/18
- [PULL 60/72] python/qmp: return generic type from context manager, John Snow, 2021/06/18
- [PULL 64/72] scripts/qmp-shell: Fix empty-transaction invocation, John Snow, 2021/06/18
- [PULL 63/72] scripts/qmp-shell: remove TODO, John Snow, 2021/06/18
- [PULL 61/72] scripts/qmp-shell: Use context manager instead of atexit, John Snow, 2021/06/18
- [PULL 66/72] scripts/qmp-shell: convert usage comment to docstring,
John Snow <=
- [PULL 68/72] scripts/qmp-shell: make QMPShellError inherit QMPError, John Snow, 2021/06/18
- [PULL 70/72] scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py, John Snow, 2021/06/18
- [PULL 72/72] scripts/qmp-shell: add redirection shim, John Snow, 2021/06/18
- [PULL 62/72] scripts/qmp-shell: use logging to show warnings, John Snow, 2021/06/18
- [PULL 65/72] scripts/qmp-shell: Remove too-broad-exception, John Snow, 2021/06/18
- [PULL 67/72] scripts/qmp-shell: remove double-underscores, John Snow, 2021/06/18
- [PULL 69/72] scripts/qmp-shell: add docstrings, John Snow, 2021/06/18
- [PULL 71/72] python: add qmp-shell entry point, John Snow, 2021/06/18
- [PULL 58/72] scripts/qmp-shell: Accept SocketAddrT instead of string, John Snow, 2021/06/18
- Re: [PULL 00/72] Python patches, Peter Maydell, 2021/06/21