Skip to content

Commit 3b79fb9

Browse files
committed
refactor(simulate): name the SIP flags --trunk, --from and --to
Matches lk sip participant create. --to-phone-number, --from-phone-number and --from-trunk came from #1035 and are not in a release, so no aliases.
1 parent e64d921 commit 3b79fb9

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

‎cmd/lk/simulate.go‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,16 @@ var simulateAudioCommand = &cli.Command{
178178
Usage: "Drop packets from the simulated user's audio track",
179179
},
180180
&cli.StringFlag{
181-
Name: "to-phone-number",
182-
Usage: "Call this `NUMBER` over SIP and simulate against whoever answers, instead of dispatching an agent. Requires --from-phone-number and --scenarios.",
181+
Name: "to",
182+
Usage: "Call this `NUMBER` (or SIP user) and simulate against whoever answers, instead of dispatching an agent. Requires --from and --scenarios.",
183183
},
184184
&cli.StringFlag{
185-
Name: "from-trunk",
186-
Usage: "Outbound SIP trunk `ID` to place --to-phone-number calls through. Without it, calls go out from a LiveKit phone number.",
185+
Name: "trunk",
186+
Usage: "Outbound SIP trunk `ID` to place --to calls through. Without it, calls go out from a LiveKit phone number.",
187187
},
188188
&cli.StringFlag{
189-
Name: "from-phone-number",
190-
Usage: "Caller `NUMBER` for --to-phone-number calls: a LiveKit phone number the project owns, or a number on --from-trunk",
189+
Name: "from",
190+
Usage: "Caller `NUMBER` for --to calls: a LiveKit phone number the project owns, or a number on --trunk",
191191
},
192192
},
193193
}
@@ -424,15 +424,15 @@ type simulateConfig struct {
424424
scenarioGroup *livekit.ScenarioGroup
425425
scenariosPath string // path to the --scenarios file (empty when generating from source)
426426
viewModeRunID string // non-empty when `view` opens a pre-existing run
427-
liveAgent bool // --agent-name or --to-phone-number: run against an already-running agent, don't spawn one
427+
liveAgent bool // --agent-name or --to: run against an already-running agent, don't spawn one
428428
warnings []string // config-level warnings surfaced at setup (e.g. ignored flags)
429429

430430
// impairments on the simulated user's audio, set only in SIMULATION_MODE_AUDIO
431431
backgroundNoise bool
432432
lowQualityMicrophone bool
433433
packetLoss bool
434434

435-
// --to-phone-number: dial this number over SIP in place of dispatching agentName
435+
// --to: dial this number over SIP in place of dispatching agentName
436436
sipCallTo string
437437
sipTrunkID string
438438
sipNumber string
@@ -541,21 +541,21 @@ func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.S
541541
samples := int32(cmd.Int("samples"))
542542
passRate := cmd.Float("pass-rate")
543543
liveAgentName := cmd.String("agent-name")
544-
var phoneNumber, fromTrunk, fromPhoneNumber string
544+
var callTo, trunkID, callFrom string
545545
if simulationMode == livekit.SimulationMode_SIMULATION_MODE_AUDIO {
546-
phoneNumber = cmd.String("to-phone-number")
547-
fromTrunk = cmd.String("from-trunk")
548-
fromPhoneNumber = cmd.String("from-phone-number")
546+
callTo = cmd.String("to")
547+
trunkID = cmd.String("trunk")
548+
callFrom = cmd.String("from")
549549
}
550-
if fromTrunk != "" && phoneNumber == "" {
551-
return fmt.Errorf("--from-trunk requires --to-phone-number")
550+
if trunkID != "" && callTo == "" {
551+
return fmt.Errorf("--trunk requires --to")
552552
}
553-
if fromPhoneNumber != "" && phoneNumber == "" {
554-
return fmt.Errorf("--from-phone-number requires --to-phone-number")
553+
if callFrom != "" && callTo == "" {
554+
return fmt.Errorf("--from requires --to")
555555
}
556556
// every call needs a caller: the number simulations are placed from
557-
if phoneNumber != "" && fromPhoneNumber == "" {
558-
return fmt.Errorf("--to-phone-number requires --from-phone-number")
557+
if callTo != "" && callFrom == "" {
558+
return fmt.Errorf("--to requires --from")
559559
}
560560

561561
// never auto-discovered: an explicit --scenarios file is the source of
@@ -582,10 +582,10 @@ func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.S
582582

583583
// --agent-name (even empty) means: run against an already-running agent,
584584
// don't spawn one. https://docs.livekit.io/agents/server/agent-dispatch/#automatic
585-
if phoneNumber != "" {
585+
if callTo != "" {
586586
// nothing is spawned, so there's no source to generate scenarios from.
587587
if scenariosPath == "" {
588-
return fmt.Errorf("--to-phone-number requires --scenarios (no source to generate scenarios from when calling a number)")
588+
return fmt.Errorf("--to requires --scenarios (no source to generate scenarios from when calling a number)")
589589
}
590590
liveAgent = true
591591
} else if cmd.IsSet("agent-name") {
@@ -669,9 +669,9 @@ func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.S
669669
simCfg.backgroundNoise = cmd.Bool("background-noise")
670670
simCfg.lowQualityMicrophone = cmd.Bool("low-quality-microphone")
671671
simCfg.packetLoss = cmd.Bool("packet-loss")
672-
simCfg.sipCallTo = phoneNumber
673-
simCfg.sipTrunkID = fromTrunk
674-
simCfg.sipNumber = fromPhoneNumber
672+
simCfg.sipCallTo = callTo
673+
simCfg.sipTrunkID = trunkID
674+
simCfg.sipNumber = callFrom
675675
}
676676

677677
if !isInteractive() {

0 commit comments

Comments
 (0)