comparison sat_frontends/jp/cmd_identity.py @ 3825:10a4846818e5

CLI (identity): add description to `identity set`: rel 368
author Goffi <goffi@goffi.org>
date Wed, 29 Jun 2022 12:13:49 +0200
parents be6d91572633
children 524856bd7b19
comparison
equal deleted inserted replaced
3824:6329ee6b6df4 3825:10a4846818e5
70 def add_parser_options(self): 70 def add_parser_options(self):
71 self.parser.add_argument( 71 self.parser.add_argument(
72 "-n", 72 "-n",
73 "--nickname", 73 "--nickname",
74 action="append", 74 action="append",
75 metavar="NICKNAME",
75 dest="nicknames", 76 dest="nicknames",
76 required=True,
77 help=_("nicknames of the entity"), 77 help=_("nicknames of the entity"),
78 )
79 self.parser.add_argument(
80 "-d",
81 "--description",
82 help=_("description of the entity"),
78 ) 83 )
79 84
80 async def start(self): 85 async def start(self):
81 id_data = { 86 id_data = {}
82 "nicknames": self.args.nicknames, 87 for field in ("nicknames", "description"):
83 } 88 value = getattr(self.args, field)
89 if value is not None:
90 id_data[field] = value
91 if not id_data:
92 self.parser.error("At least one metadata must be set")
84 try: 93 try:
85 self.host.bridge.identitySet( 94 self.host.bridge.identitySet(
86 data_format.serialise(id_data), 95 data_format.serialise(id_data),
87 self.profile, 96 self.profile,
88 ) 97 )