From 77ca8bbf0f077fc8b5058e97ccdde8c40bc641f7 Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Thu, 18 Jun 2015 17:07:03 +0200 Subject: [PATCH] artiq_coreconfig: better arg parsing --- artiq/frontend/artiq_coreconfig.py | 6 +++--- doc/manual/utilities.rst | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/artiq/frontend/artiq_coreconfig.py b/artiq/frontend/artiq_coreconfig.py index d5289bdb4..9eb39d7fc 100755 --- a/artiq/frontend/artiq_coreconfig.py +++ b/artiq/frontend/artiq_coreconfig.py @@ -17,7 +17,7 @@ def get_argparser(): subparsers.required = True p_read = subparsers.add_parser("read", help="read key from core device config") - p_read.add_argument("-k", "--key", type=to_bytes, required=True, + p_read.add_argument("key", type=to_bytes, help="key to be read from core device config") p_write = subparsers.add_parser("write", help="write key-value records to core " @@ -34,8 +34,8 @@ def get_argparser(): subparsers.add_parser("erase", help="erase core device config") p_delete = subparsers.add_parser("delete", help="delete key from core device config") - p_delete.add_argument("-k", "--key", action="append", default=[], - type=to_bytes, required=True, + p_delete.add_argument("key", nargs=argparse.REMAINDER, + default=[], type=to_bytes, help="key to be deleted from core device config") parser.add_argument("--ddb", default="ddb.pyon", help="device database file") diff --git a/doc/manual/utilities.rst b/doc/manual/utilities.rst index a27d7d8d7..a507291ae 100644 --- a/doc/manual/utilities.rst +++ b/doc/manual/utilities.rst @@ -109,18 +109,18 @@ When not specified, the artiq_coreconfig tool will assume that there is a file n To read the record whose key is ``mac``:: - $ artiq_coreconfig read -k mac + $ artiq_coreconfig read mac To write the value ``test_value`` in the key ``my_key``:: $ artiq_coreconfig write -s my_key test_value - $ artiq_coreconfig read -k my_key + $ artiq_coreconfig read my_key b'test_value' You can also write entire files in a record using the ``-f`` parameter. This is useful for instance to write the ``idle`` kernel in the flash storage:: $ artiq_coreconfig write -f idle_kernel idle.elf - $ artiq_coreconfig read -k idle_kernel | head -c9 + $ artiq_coreconfig read idle_kernel | head -c9 b'\x7fELF You can write several records at once:: @@ -129,7 +129,11 @@ You can write several records at once:: To remove the previously written key ``my_key``:: - $ artiq_coreconfig delete -k my_key + $ artiq_coreconfig delete my_key + +You can remove several keys at once:: + + $ artiq_coreconfig delete key1 key2 To erase the entire flash storage area:: @@ -140,7 +144,7 @@ it:: $ artiq_coreconfig write -s my_key some_value $ artiq_coreconfig write -s my_key some_other_value - $ artiq_coreconfig read -k my_key + $ artiq_coreconfig read my_key b'some_other_value' .. argparse::