forked from M-Labs/artiq
artiq_coreconfig: better arg parsing
This commit is contained in:
parent
d25a07f668
commit
77ca8bbf0f
|
@ -17,7 +17,7 @@ def get_argparser():
|
||||||
subparsers.required = True
|
subparsers.required = True
|
||||||
p_read = subparsers.add_parser("read",
|
p_read = subparsers.add_parser("read",
|
||||||
help="read key from core device config")
|
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")
|
help="key to be read from core device config")
|
||||||
p_write = subparsers.add_parser("write",
|
p_write = subparsers.add_parser("write",
|
||||||
help="write key-value records to core "
|
help="write key-value records to core "
|
||||||
|
@ -34,8 +34,8 @@ def get_argparser():
|
||||||
subparsers.add_parser("erase", help="erase core device config")
|
subparsers.add_parser("erase", help="erase core device config")
|
||||||
p_delete = subparsers.add_parser("delete",
|
p_delete = subparsers.add_parser("delete",
|
||||||
help="delete key from core device config")
|
help="delete key from core device config")
|
||||||
p_delete.add_argument("-k", "--key", action="append", default=[],
|
p_delete.add_argument("key", nargs=argparse.REMAINDER,
|
||||||
type=to_bytes, required=True,
|
default=[], type=to_bytes,
|
||||||
help="key to be deleted from core device config")
|
help="key to be deleted from core device config")
|
||||||
parser.add_argument("--ddb", default="ddb.pyon",
|
parser.add_argument("--ddb", default="ddb.pyon",
|
||||||
help="device database file")
|
help="device database file")
|
||||||
|
|
|
@ -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``::
|
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``::
|
To write the value ``test_value`` in the key ``my_key``::
|
||||||
|
|
||||||
$ artiq_coreconfig write -s my_key test_value
|
$ artiq_coreconfig write -s my_key test_value
|
||||||
$ artiq_coreconfig read -k my_key
|
$ artiq_coreconfig read my_key
|
||||||
b'test_value'
|
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::
|
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 write -f idle_kernel idle.elf
|
||||||
$ artiq_coreconfig read -k idle_kernel | head -c9
|
$ artiq_coreconfig read idle_kernel | head -c9
|
||||||
b'\x7fELF
|
b'\x7fELF
|
||||||
|
|
||||||
You can write several records at once::
|
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``::
|
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::
|
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_value
|
||||||
$ artiq_coreconfig write -s my_key some_other_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'
|
b'some_other_value'
|
||||||
|
|
||||||
.. argparse::
|
.. argparse::
|
||||||
|
|
Loading…
Reference in New Issue