Skip to content

Commit

Permalink
tools: ynl-gen-c: annotate valid choices for --mode
Browse files Browse the repository at this point in the history
This makes argparse validate the input and helps users
understand which modes are possible.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20241206113100.e2ab5cf6937c.Ie149a0ca5df713860964b44fe9d9ae547f2e1553@changeid
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Johannes Berg authored and Jakub Kicinski committed Dec 8, 2024
1 parent 860dbab commit 00ab246
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/net/ynl/ynl-gen-c.py
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,8 @@ def find_kernel_root(full_path):

def main():
parser = argparse.ArgumentParser(description='Netlink simple parsing generator')
parser.add_argument('--mode', dest='mode', type=str, required=True)
parser.add_argument('--mode', dest='mode', type=str, required=True,
choices=('user', 'kernel', 'uapi'))
parser.add_argument('--spec', dest='spec', type=str, required=True)
parser.add_argument('--header', dest='header', action='store_true', default=None)
parser.add_argument('--source', dest='header', action='store_false')
Expand Down

0 comments on commit 00ab246

Please sign in to comment.