CLI: move most top-level args down into the subcommand
So instead of "wormhole --verify send", use "wormhole send --verify". The full set of arguments that were moved down: * --code-length= * --verify * --hide-progress * --no-listen * --tor The following remain as top-level arguments (which should appear after "wormhole" and before the subcommand): * --relay-url= * --transit-helper= * --dump-timing= * --version
This commit is contained in:
parent
894e00bea1
commit
5542545165
12
README.md
12
README.md
|
@ -149,15 +149,13 @@ provide information about alternatives.
|
|||
|
||||
## CLI tool
|
||||
|
||||
* `wormhole send --text TEXT`
|
||||
* `wormhole send FILENAME`
|
||||
* `wormhole send DIRNAME`
|
||||
* `wormhole receive`
|
||||
* `wormhole send [args] --text TEXT`
|
||||
* `wormhole send [args] FILENAME`
|
||||
* `wormhole send [args] DIRNAME`
|
||||
* `wormhole receive [args]`
|
||||
|
||||
Both commands accept:
|
||||
Both commands accept additional arguments to influence their behavior:
|
||||
|
||||
* `--relay-url URL` : override the rendezvous server URL
|
||||
* `--transit-helper tcp:HOST:PORT`: override the Transit Relay
|
||||
* `--code-length WORDS`: use more or fewer than 2 words for the code
|
||||
* `--verify` : print (and ask user to compare) extra verification string
|
||||
|
||||
|
|
|
@ -48,27 +48,8 @@ class AliasedGroup(click.Group):
|
|||
return click.Group.get_command(self, ctx, cmd_name)
|
||||
|
||||
|
||||
TopArgs = _compose(
|
||||
click.option("-c", "--code-length", default=2, metavar="NUMWORDS",
|
||||
help="length of code (in bytes/words)",
|
||||
),
|
||||
click.option("-v", "--verify", is_flag=True, default=False,
|
||||
help="display verification string (and wait for approval)",
|
||||
),
|
||||
click.option("--hide-progress", is_flag=True, default=False,
|
||||
help="supress progress-bar display",
|
||||
),
|
||||
click.option("--no-listen", is_flag=True, default=False,
|
||||
help="(debug) don't open a listening socket for Transit",
|
||||
),
|
||||
click.option("--tor", is_flag=True, default=False,
|
||||
help="use Tor when connecting",
|
||||
),
|
||||
)
|
||||
|
||||
# top-level command ("wormhole ...")
|
||||
@click.group(cls=AliasedGroup)
|
||||
@TopArgs
|
||||
@click.option(
|
||||
"--relay-url", default=public_relay.RENDEZVOUS_RELAY,
|
||||
metavar="URL",
|
||||
|
@ -90,8 +71,7 @@ TopArgs = _compose(
|
|||
version=__version__,
|
||||
)
|
||||
@click.pass_context
|
||||
def wormhole(context, tor, no_listen, dump_timing, hide_progress,
|
||||
verify, code_length, transit_helper, relay_url):
|
||||
def wormhole(context, dump_timing, transit_helper, relay_url):
|
||||
"""
|
||||
Create a Magic Wormhole and communicate through it.
|
||||
|
||||
|
@ -100,13 +80,8 @@ def wormhole(context, tor, no_listen, dump_timing, hide_progress,
|
|||
anyone who doesn't use the same code.
|
||||
"""
|
||||
context.obj = cfg = Config()
|
||||
cfg.tor = tor
|
||||
cfg.listen = not no_listen
|
||||
cfg.relay_url = relay_url
|
||||
cfg.transit_helper = transit_helper
|
||||
cfg.code_length = code_length
|
||||
cfg.verify = verify
|
||||
cfg.hide_progress = hide_progress
|
||||
cfg.dump_timing = dump_timing
|
||||
|
||||
|
||||
|
@ -147,6 +122,21 @@ CommonArgs = _compose(
|
|||
click.option("-0", "zeromode", default=False, is_flag=True,
|
||||
help="enable no-code anything-goes mode",
|
||||
),
|
||||
click.option("-c", "--code-length", default=2, metavar="NUMWORDS",
|
||||
help="length of code (in bytes/words)",
|
||||
),
|
||||
click.option("-v", "--verify", is_flag=True, default=False,
|
||||
help="display verification string (and wait for approval)",
|
||||
),
|
||||
click.option("--hide-progress", is_flag=True, default=False,
|
||||
help="supress progress-bar display",
|
||||
),
|
||||
click.option("--listen/--no-listen", default=True,
|
||||
help="(debug) don't open a listening socket for Transit",
|
||||
),
|
||||
click.option("--tor", is_flag=True, default=False,
|
||||
help="use Tor when connecting",
|
||||
),
|
||||
)
|
||||
|
||||
# wormhole send (or "wormhole tx")
|
||||
|
|
|
@ -33,7 +33,7 @@ class Send(unittest.TestCase):
|
|||
self.assertEqual(cfg.text, u"hi")
|
||||
|
||||
def test_nolisten(self):
|
||||
cfg = config("--no-listen", "send", "fn")
|
||||
cfg = config("send", "--no-listen", "fn")
|
||||
self.assertEqual(cfg.listen, False)
|
||||
|
||||
def test_code(self):
|
||||
|
@ -41,7 +41,7 @@ class Send(unittest.TestCase):
|
|||
self.assertEqual(cfg.code, u"1-abc")
|
||||
|
||||
def test_code_length(self):
|
||||
cfg = config("-c", "3", "send", "fn")
|
||||
cfg = config("send", "-c", "3", "fn")
|
||||
self.assertEqual(cfg.code_length, 3)
|
||||
|
||||
def test_dump_timing(self):
|
||||
|
@ -49,15 +49,15 @@ class Send(unittest.TestCase):
|
|||
self.assertEqual(cfg.dump_timing, "tx.json")
|
||||
|
||||
def test_hide_progress(self):
|
||||
cfg = config("--hide-progress", "send", "fn")
|
||||
cfg = config("send", "--hide-progress", "fn")
|
||||
self.assertEqual(cfg.hide_progress, True)
|
||||
|
||||
def test_tor(self):
|
||||
cfg = config("--tor", "send", "fn")
|
||||
cfg = config("send", "--tor", "fn")
|
||||
self.assertEqual(cfg.tor, True)
|
||||
|
||||
def test_verify(self):
|
||||
cfg = config("--verify", "send", "fn")
|
||||
cfg = config("send", "--verify", "fn")
|
||||
self.assertEqual(cfg.verify, True)
|
||||
|
||||
def test_zeromode(self):
|
||||
|
@ -83,7 +83,7 @@ class Receive(unittest.TestCase):
|
|||
self.assertEqual(cfg.zeromode, False)
|
||||
|
||||
def test_nolisten(self):
|
||||
cfg = config("--no-listen", "receive")
|
||||
cfg = config("receive", "--no-listen")
|
||||
self.assertEqual(cfg.listen, False)
|
||||
|
||||
def test_code(self):
|
||||
|
@ -91,7 +91,7 @@ class Receive(unittest.TestCase):
|
|||
self.assertEqual(cfg.code, u"1-abc")
|
||||
|
||||
def test_code_length(self):
|
||||
cfg = config("-c", "3", "receive")
|
||||
cfg = config("receive", "-c", "3")
|
||||
self.assertEqual(cfg.code_length, 3)
|
||||
|
||||
def test_dump_timing(self):
|
||||
|
@ -99,15 +99,15 @@ class Receive(unittest.TestCase):
|
|||
self.assertEqual(cfg.dump_timing, "tx.json")
|
||||
|
||||
def test_hide_progress(self):
|
||||
cfg = config("--hide-progress", "receive")
|
||||
cfg = config("receive", "--hide-progress")
|
||||
self.assertEqual(cfg.hide_progress, True)
|
||||
|
||||
def test_tor(self):
|
||||
cfg = config("--tor", "receive")
|
||||
cfg = config("receive", "--tor")
|
||||
self.assertEqual(cfg.tor, True)
|
||||
|
||||
def test_verify(self):
|
||||
cfg = config("--verify", "receive")
|
||||
cfg = config("receive", "--verify")
|
||||
self.assertEqual(cfg.verify, True)
|
||||
|
||||
def test_zeromode(self):
|
||||
|
|
|
@ -298,10 +298,10 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
|
|||
content_args = [send_cfg.what]
|
||||
|
||||
send_args = [
|
||||
'--hide-progress',
|
||||
'--relay-url', self.relayurl,
|
||||
'--transit-helper', '',
|
||||
'send',
|
||||
'--hide-progress',
|
||||
'--code', send_cfg.code,
|
||||
] + content_args
|
||||
|
||||
|
@ -311,10 +311,10 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase):
|
|||
env=dict(LC_ALL="en_US.UTF-8", LANG="en_US.UTF-8"),
|
||||
)
|
||||
recv_args = [
|
||||
'--hide-progress',
|
||||
'--relay-url', self.relayurl,
|
||||
'--transit-helper', '',
|
||||
'receive',
|
||||
'--hide-progress',
|
||||
'--accept-file',
|
||||
recv_cfg.code,
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue
Block a user