Pseudo-Commands
Overview
A pseudo-command is a built-in command keyword recognized by the Bulk Actions feature. Unlike shell executables (e.g., ping or dig which invoke system binaries via Runtime.exec), pseudo-commands trigger custom Kotlin code directly inside BulkActionsRepository. There are 9 pseudo-commands:
| Keyword | Purpose |
|---|---|
ping | ICMP ping |
dig | DNS resolution (via dnsjava) |
ntp | NTP time query |
port-scan | TCP port scan |
checkcert | HTTPS certificate inspection |
device-info | Device identity info |
tracert | Traceroute (TTL probing) |
google-timesync | Google Time Sync |
lan-scan | LAN subnet ping sweep |
Unrecognized keywords fall through to a raw Runtime.exec() fallback.
How It Works
JSON config file
"commands": {
"ping_google": "ping -c 5 google.com",
"dig_example": "dig example.com",
"checkcert_google": "checkcert https://google.com"
}
β
βΌ
BulkConfigParser.parse(json) β parses JSON into BulkConfig(commands=Map<String, String>)
β
βΌ
BulkActionsViewModel.onLoadAndRun() β reads config, stores in UI state
β
βΌ
BulkActionsRepository.executeAllCommands(commands)
β
βββ For each (name, cmd) pair:
β executeSingleCommand(name, cmd, timeoutMs)
β β
β βββ Parse first word β dispatch via `when`:
β "ping" β executePing() β Runtime.exec("ping -c 5 google.com")
β "dig" β executeDig() β DigRepository.resolve()
β "ntp" β executeNtp() β NtpRepository.query()
β "port-scan" β executePortScan() β Socket.connect(port, timeout) Γ N
β "checkcert" β executeCheckcert() β HttpsCertRepository.fetchCertificate()
β "device-info" β executeDeviceInfo() β SystemInfoRepository.getDeviceInfo()
β "tracert" β executeTracert() β Runtime.exec("ping -c 1 -t TTL host")
β "google-timesync" β executeGoogleTimeSync() β GoogleTimeSyncRepository.fetchGoogleTime()
β "lan-scan" β executeLanScan() β LanScannerRepository.pingSweep()
β else β executeRaw() β Runtime.exec(full string)
β
βΌ
BulkCommandResult (sealed hierarchy)
βββ BulkCommandSuccess β succeeded with output lines
βββ BulkCommandError β failed with error message
βββ BulkCommandTimeout β timed out
βββ BulkCommandClosed β manually stopped
βββ BulkCommandWarning β succeeded but with a warning (e.g. expired cert)
β
ββββ BulkActionsViewModel.generateOutputContent() β text report with summary table
ββββ BulkActionsViewModel.generateCsvContent() β CSV export
ββββ BulkActionsScreen.ResultItem() β Compose UI display (icon + lines)Key Classes
| Class | Role |
|---|---|
BulkConfigParser | Parses JSON config into BulkConfig data class |
BulkActionsRepository.executeSingleCommand() | Dispatches each command keyword to the correct executor |
executePing() β¦ executeLanScan() | 9 private executors β invoke repositories or system binaries |
BulkCommandResult (+ subclasses) | Sealed hierarchy representing execution outcomes |
BulkActionsViewModel.generateOutputContent() | Formats results into a text report with summary table |
BulkActionsViewModel.generateCsvContent() | Formats results as CSV |
BulkActionsScreen.ResultItem() | Renders each result in the Compose UI (icon + status + output lines) |