mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-16 07:06:43 +00:00
Add user-facing help about destinations
This commit is contained in:
parent
1cf4fd46ed
commit
7fb695f956
@ -12,6 +12,7 @@ from allmydata.scripts import debug, create_node, cli, \
|
||||
from allmydata.util.encodingutil import quote_output, quote_local_unicode_path, get_io_encoding
|
||||
from allmydata.util.eliotutil import (
|
||||
opt_eliot_destination,
|
||||
opt_help_eliot_destinations,
|
||||
)
|
||||
|
||||
def GROUP(s):
|
||||
@ -93,6 +94,7 @@ class Options(usage.Options):
|
||||
self.no_command_needed = True
|
||||
|
||||
opt_eliot_destination = opt_eliot_destination
|
||||
opt_help_eliot_destinations = opt_help_eliot_destinations
|
||||
|
||||
def __str__(self):
|
||||
return ("\nUsage: tahoe [global-options] <command> [command-options]\n"
|
||||
|
@ -168,6 +168,25 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, RunBinTahoeMixin):
|
||||
d.addCallback(_cb)
|
||||
return d
|
||||
|
||||
@inlineCallbacks
|
||||
def test_help_eliot_destinations(self):
|
||||
out, err, rc_or_sig = yield self.run_bintahoe(["--help-eliot-destinations"])
|
||||
self.assertIn("\tfile:<path>", out)
|
||||
self.assertEqual(rc_or_sig, 0)
|
||||
|
||||
@inlineCallbacks
|
||||
def test_eliot_destination(self):
|
||||
out, err, rc_or_sig = yield self.run_bintahoe([
|
||||
# Proves little but maybe more than nothing.
|
||||
"--eliot-destination=file:-",
|
||||
# Throw in *some* command or the process exits with error, making
|
||||
# it difficult for us to see if the previous arg was accepted or
|
||||
# not.
|
||||
"--help",
|
||||
])
|
||||
self.assertEqual(rc_or_sig, 0)
|
||||
|
||||
|
||||
|
||||
class CreateNode(unittest.TestCase):
|
||||
# exercise "tahoe create-node", create-introducer,
|
||||
|
@ -15,6 +15,7 @@ __all__ = [
|
||||
"inline_callbacks",
|
||||
"eliot_logging_service",
|
||||
"opt_eliot_destination",
|
||||
"opt_help_eliot_destinations",
|
||||
]
|
||||
|
||||
from sys import (
|
||||
@ -190,11 +191,8 @@ def eliot_logging_service(reactor, destinations):
|
||||
Parse the given Eliot destination descriptions and return an ``IService``
|
||||
which will add them when started and remove them when stopped.
|
||||
|
||||
The following destinations are supported:
|
||||
|
||||
* ``file:<path>[:rotated_length=<bytes>][:max_rotated_files=<count>]``
|
||||
Sensible defaults are supplied for rotated_length and max_rotated_files
|
||||
if they are not given.
|
||||
See ``--help-eliot-destinations`` for details about supported
|
||||
destinations.
|
||||
"""
|
||||
return _EliotLogging(destinations=list(
|
||||
get_destination(reactor)
|
||||
@ -214,6 +212,22 @@ def opt_eliot_destination(self, description):
|
||||
)
|
||||
|
||||
|
||||
def opt_help_eliot_destinations(self):
|
||||
"""
|
||||
Emit usage information for --eliot-destination.
|
||||
"""
|
||||
print(
|
||||
"Available destinations:\n"
|
||||
# Might want to generate this from some metadata someday but we just
|
||||
# have one hard-coded destination type now, it's easier to hard-code
|
||||
# the help.
|
||||
"\tfile:<path>[:rotate_length=<bytes>][:max_rotated_files=<count>]\n"
|
||||
"\tSensible defaults are supplied for rotate_length and max_rotated_files\n"
|
||||
"\tif they are not given.\n",
|
||||
file=self.stdout,
|
||||
)
|
||||
raise SystemExit(0)
|
||||
|
||||
|
||||
class _EliotLogging(Service):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user