Skip to content

Commit 77ca8bb

Browse files
committedJun 18, 2015
artiq_coreconfig: better arg parsing
1 parent d25a07f commit 77ca8bb

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed
 

Diff for: ‎artiq/frontend/artiq_coreconfig.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_argparser():
1717
subparsers.required = True
1818
p_read = subparsers.add_parser("read",
1919
help="read key from core device config")
20-
p_read.add_argument("-k", "--key", type=to_bytes, required=True,
20+
p_read.add_argument("key", type=to_bytes,
2121
help="key to be read from core device config")
2222
p_write = subparsers.add_parser("write",
2323
help="write key-value records to core "
@@ -34,8 +34,8 @@ def get_argparser():
3434
subparsers.add_parser("erase", help="erase core device config")
3535
p_delete = subparsers.add_parser("delete",
3636
help="delete key from core device config")
37-
p_delete.add_argument("-k", "--key", action="append", default=[],
38-
type=to_bytes, required=True,
37+
p_delete.add_argument("key", nargs=argparse.REMAINDER,
38+
default=[], type=to_bytes,
3939
help="key to be deleted from core device config")
4040
parser.add_argument("--ddb", default="ddb.pyon",
4141
help="device database file")

Diff for: ‎doc/manual/utilities.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ When not specified, the artiq_coreconfig tool will assume that there is a file n
109109

110110
To read the record whose key is ``mac``::
111111

112-
$ artiq_coreconfig read -k mac
112+
$ artiq_coreconfig read mac
113113

114114
To write the value ``test_value`` in the key ``my_key``::
115115

116116
$ artiq_coreconfig write -s my_key test_value
117-
$ artiq_coreconfig read -k my_key
117+
$ artiq_coreconfig read my_key
118118
b'test_value'
119119

120120
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::
121121

122122
$ artiq_coreconfig write -f idle_kernel idle.elf
123-
$ artiq_coreconfig read -k idle_kernel | head -c9
123+
$ artiq_coreconfig read idle_kernel | head -c9
124124
b'\x7fELF
125125

126126
You can write several records at once::
@@ -129,7 +129,11 @@ You can write several records at once::
129129

130130
To remove the previously written key ``my_key``::
131131

132-
$ artiq_coreconfig delete -k my_key
132+
$ artiq_coreconfig delete my_key
133+
134+
You can remove several keys at once::
135+
136+
$ artiq_coreconfig delete key1 key2
133137

134138
To erase the entire flash storage area::
135139

@@ -140,7 +144,7 @@ it::
140144

141145
$ artiq_coreconfig write -s my_key some_value
142146
$ artiq_coreconfig write -s my_key some_other_value
143-
$ artiq_coreconfig read -k my_key
147+
$ artiq_coreconfig read my_key
144148
b'some_other_value'
145149

146150
.. argparse::

0 commit comments

Comments
 (0)
Please sign in to comment.