pySim-shell: let --apdu-trace cover the session

pySim has two APDU tracers: the StdoutApduTracer that --apdu-trace
installs in the transport for every program using pySim.transport, and
pySim-shell Cmd2ApduTracer for "set apdu_trace true", which prints with
cmd2. The command line option exists because the setting
applies too late to see the pySim startup APDUs.

The guard in init_reader() exists but is useless:
    if opts.apdu_trace and not 'apdu_tracer' in kwargs:
no caller supplies a tracer that way, every tool calls init_reader()
without one?.

The current help string does not say "trace or maybe not lol" so set
the setting from the transport rather than hardcoding False, so the
option implies "set apdu_trace true", and it finally works as advertised.

Change-Id: I83469e15f4cdd67418cd11df3869f2536105dbc8
This commit is contained in:
Eric Wild
2026-09-23 17:51:04 +02:00
parent 26a3fc09dc
commit 37719a0fcf
+1 -1
View File
@@ -101,7 +101,7 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/
self.numeric_path = False
self.conserve_write = True
self.json_pretty_print = True
self.apdu_trace = False
self.apdu_trace = getattr(sl, 'apdu_tracer', None) is not None
self.apdu_strict = False
self.add_settable(cmd2.Settable('numeric_path', bool,