meejah / carml

Command-line utility to control Tor.
http://tvflhlyx7o5qsl6a2v6pvzwripzzvzgt32tkhfbys7tj3zrm4faz53yd.onion/
The Unlicense
88 stars 12 forks source link

Update relay --await option - add name 'awaiting' #38

Closed rprimus closed 5 years ago

rprimus commented 5 years ago

Sun Dec 16 23:48:07 GMT 2018

Addendum to PR #35

meejah commented 5 years ago

Instead of changing the option as visible to the command-line, I think it's possible to tell Click that the "arg name for this option" is "awaiting" (and leave the cli as --await)..?

rprimus commented 5 years ago

Mon Dec 17 06:09:50 GMT 2018

With:

@click.option(
    '--await',
    default='',
    help='Monitor NEWCONSENSUS for a fingerprint to exist',
)

The following is generated using relay:

: ; carml --connect tcp:localhost:9051 relay
Traceback (most recent call last):
  File "/Users/rprimus/.pyenv/versions/v/bin/carml", line 11, in <module>
    load_entry_point('carml', 'console_scripts', 'carml')()
  File "/Users/rprimus/.pyenv/versions/3.7.1/envs/v/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/rprimus/.pyenv/versions/3.7.1/envs/v/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/rprimus/.pyenv/versions/3.7.1/envs/v/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/rprimus/.pyenv/versions/3.7.1/envs/v/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/rprimus/.pyenv/versions/3.7.1/envs/v/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/rprimus/.pyenv/versions/3.7.1/envs/v/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
TypeError: relay() got an unexpected keyword argument 'await'
meejah commented 5 years ago

Looks like you should be able to append a 'awaiting' to the option to tell Click to use that as the name: https://click.palletsprojects.com/en/7.x/options/#name-your-options

So like: ``` @click.option( '--await', 'awaiting', default='', help='Monitor NEWCONSENSUS for a fingerprint to exist', )

rprimus commented 5 years ago

Mon Dec 17 17:10:28 GMT 2018

Ahhh! Thanks for the link - all clear now. PR updated.

meejah commented 5 years ago

awesome, thanks!

meejah commented 5 years ago

p.s. I just added some release-notes for your changes .. always feel free to add similar if you're motivated for future PRs :)