Skip to content

Commit 3835653

Browse files
committed
feat(logs): support custom file paths
1 parent e442620 commit 3835653

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

mwutil/modules/logs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from argparse import ArgumentParser, Namespace
22

3+
from argcomplete import ChoicesCompleter
4+
35
from mwutil.files import FileWrapper
46
from mwutil.local_config import MWUtilConfig
57
from mwutil.module import MWUtilModule
@@ -22,11 +24,11 @@ def populate_subparser(self, parser: ArgumentParser, config: MWUtilConfig):
2224
parser.add_argument(
2325
"file",
2426
type=str,
25-
choices=self.FILES.keys()
26-
)
27+
help="One of the options (e.g. dberror), or a custom file path (e.g. mariadb:///var/log/bootstrap.log)"
28+
).completer = ChoicesCompleter(self.FILES.keys())
2729

2830
def execute(self, config: MWUtilConfig, args: Namespace):
2931
file = args.file
30-
template = self.FILES.get(file)
32+
template = self.FILES.get(file) or file
3133
file = FileWrapper.from_path(config, template)
3234
file.stream_to_stdout()

0 commit comments

Comments
 (0)