Transfer response_timeout

This commit is contained in:
Kovid Goyal 2022-08-17 13:33:24 +05:30
parent a5876e5231
commit 605882582e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 3 deletions

View File

@ -34,6 +34,7 @@ class Option:
self.short, self.long = short, long self.short, self.long = short, long
self.usage = serialize_as_go_string(x['help'].strip()) self.usage = serialize_as_go_string(x['help'].strip())
self.type = x['type'] self.type = x['type']
self.dest = x['dest']
def to_flag_definition(self, base: str = 'ans.Flags()') -> str: def to_flag_definition(self, base: str = 'ans.Flags()') -> str:
if self.type == 'bool-set': if self.type == 'bool-set':
@ -53,12 +54,16 @@ def build_go_code(name: str, cmd: RemoteCommand, seq: OptionSpecSeq, template: s
continue continue
o = Option(x) o = Option(x)
a(o.to_flag_definition()) a(o.to_flag_definition())
if o.dest == 'no_response':
continue
ans = replace( ans = replace(
template, template,
CMD_NAME=name, __FILE__=__file__, CLI_NAME=name.replace('_', '-'), CMD_NAME=name, __FILE__=__file__, CLI_NAME=name.replace('_', '-'),
SHORT_DESC=serialize_as_go_string(cmd.short_desc), SHORT_DESC=serialize_as_go_string(cmd.short_desc),
LONG_DESC=serialize_as_go_string(cmd.desc.strip()), LONG_DESC=serialize_as_go_string(cmd.desc.strip()),
NO_RESPONSE_BASE=NO_RESPONSE_BASE, ADD_FLAGS_CODE='\n'.join(af)) NO_RESPONSE_BASE=NO_RESPONSE_BASE, ADD_FLAGS_CODE='\n'.join(af),
WAIT_TIMEOUT=str(cmd.response_timeout),
)
return ans return ans

View File

@ -90,7 +90,7 @@ func create_serializer(password string, encoded_pubkey string) (ans serializer_f
return simple_serializer, nil return simple_serializer, nil
} }
func send_rc_command(rc *utils.RemoteControlCmd) (err error) { func send_rc_command(rc *utils.RemoteControlCmd, timeout float64) (err error) {
serializer, err = create_serializer(global_options.password, "") serializer, err = create_serializer(global_options.password, "")
if err != nil { if err != nil {
return return

View File

@ -21,7 +21,7 @@ func run_CMD_NAME(cmd *cobra.Command, args []string) (err error) {
if err == nil { if err == nil {
rc.NoResponse = nrv rc.NoResponse = nrv
} }
err = send_rc_command(&rc) err = send_rc_command(&rc, WAIT_TIMEOUT)
return return
} }