Skip to content

Commit 3874213

Browse files
committed
docs: add usage examples to command line help output
Signed-off-by: Christopher Arndt <[email protected]>
1 parent 0fd0c8c commit 3874213

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

jackmatchmaker/__init__.py

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,42 @@
1-
"""Auto-connect new JACK ports matching the patterns given on the command line."""
1+
"""Auto-connect new JACK ports matching the patterns given on the command line.
2+
3+
Examples:
4+
5+
List all JACK input and output ports, including their aliases and pretty names:
6+
7+
jack-matchmaker -ioan
8+
9+
List all existing connections between ports, or only those where at least one
10+
port matches one given PATTERN:
11+
12+
jack-matchmaker -c [PATTERN, ...]
13+
14+
Auto-connect the ports 'left' and 'right' of JACK client 'fluidsynth' to the
15+
system audio playback ports using exact matching mode:
16+
17+
jack-matchmaker -e fluidsynth:left system:playback_1 fluidsynth:right system:playback_2
18+
19+
Auto-connect all ports of client 'mixer' starting with 'l_' to
20+
'system:playback_1' and all starting with 'r_' to 'system:playback_2':
21+
22+
jack-matchmaker 'mixer:l_.*' system:playback_1 'mixer:r_.*' system:playback_2
23+
24+
Auto-connect ports starting with 'midi' (case-insensitive) of any client to
25+
'midi-monitor:input':
26+
27+
jack-matchmaker '(?i).*:midi.*' midi-monitor:input
28+
29+
Auto-connect system MIDI caspture ports to the respective 'midi_in_track_'
30+
ports of client 'mydaw' with the corresponding number suffix:
31+
32+
jack-matchmaker 'system:midi_capture_(?P<num>\d+)$' 'mydaw:midi_in_track_{num}'
33+
34+
Read port patterns from file 'patterns.txt' and run in verbose mode:
35+
36+
jack-matchmaker -v -p patterns.txt
37+
38+
See https://github.com/SpotlightKid/jack-matchmaker for more examples.
39+
"""
240

341
import argparse
442
import logging
@@ -403,7 +441,14 @@ def run(self):
403441

404442

405443
def main(args=None):
406-
ap = argparse.ArgumentParser(prog=__program__, description=__doc__.splitlines()[0])
444+
doclines = __doc__.splitlines()
445+
ap = argparse.ArgumentParser(
446+
prog=__program__,
447+
description=doclines[0],
448+
epilog="\n".join(doclines[2:]),
449+
formatter_class=argparse.RawDescriptionHelpFormatter
450+
)
451+
del doclines
407452
apg = ap.add_argument_group('actions', 'Listing ports and connections')
408453
apg.add_argument('-c', '--list-connections', dest="actions", action="append_const",
409454
const="list_cnx", help="List all connections between JACK ports "
@@ -446,10 +491,14 @@ def main(args=None):
446491

447492
if args.actions or args.patterns or args.pattern_file:
448493
try:
449-
matchmaker = JackMatchmaker(pairwise(args.patterns), args.pattern_file,
450-
name=args.client_name, exact_matching=args.exact_matching,
451-
connect_interval=args.connect_interval,
452-
connect_max_attempts=args.max_attempts)
494+
matchmaker = JackMatchmaker(
495+
pairwise(args.patterns),
496+
args.pattern_file,
497+
name=args.client_name,
498+
exact_matching=args.exact_matching,
499+
connect_interval=args.connect_interval,
500+
connect_max_attempts=args.max_attempts
501+
)
453502
except (OSError, RuntimeError) as exc:
454503
return str(exc)
455504
else:
@@ -477,6 +526,7 @@ def main(args=None):
477526
log.exception("Startup error")
478527
else:
479528
log.error("Startup error: %s", exc)
529+
480530
return str(exc)
481531
finally:
482532
matchmaker.close()

0 commit comments

Comments
 (0)