fr
Pseudo-commandes

Pseudo Commandes

Vue d'ensemble

Une pseudo-commande est un mot-clé intégré reconnu par la fonctionnalité Actions en Lots. Contrairement aux exécutables shell (par ex. ping ou dig qui invoquent des binaires systÚme via Runtime.exec), les pseudo-commandes déclenchent du code Kotlin personnalisé directement dans BulkActionsRepository. Il existe 9 pseudo-commandes :

Mot-cléObjectif
pingPing ICMP
digRésolution DNS (via dnsjava)
ntpRequĂȘte de temps NTP
port-scanScan de ports TCP
checkcertInspection de certificats HTTPS
device-infoInfos d'identité de l'appareil
tracertTraceroute (sondage TTL)
google-timesyncGoogle Time Sync
lan-scanBalayage de sous-réseau LAN

Les mots-clés non reconnus passent par un fallback Runtime.exec() brut.

Comment ça fonctionne

Fichier de config JSON
    "commands": {
      "ping_google":        "ping -c 5 google.com",
      "dig_example":        "dig example.com",
      "checkcert_google": "checkcert https://google.com"
    }
         │
         ▌
BulkConfigParser.parse(json)           ← analyse JSON en BulkConfig(commands=Map<String, String>)
         │
         ▌
BulkActionsViewModel.onLoadAndRun()    ← lit la config, stocke dans l'Ă©tat UI
         │
         ▌
BulkActionsRepository.executeAllCommands(commands)
         │
         ├── Pour chaque paire (nom, cmd) :
         │    executeSingleCommand(nom, cmd, timeoutMs)
         │        │
         │        └── Analyse du premier mot → 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    (hiérarchie scellée)
    ├── BulkCommandSuccess     — rĂ©ussi avec lignes de sortie
    ├── BulkCommandError       — Ă©chouĂ© avec message d'erreur
    ├── BulkCommandTimeout     — dĂ©lai d'attente dĂ©passĂ©
    ├── BulkCommandClosed      — arrĂȘtĂ© manuellement
    └── BulkCommandWarning     — rĂ©ussi mais avec un avertissement (ex: cert expirĂ©)
         │
         ├──→ BulkActionsViewModel.generateOutputContent()    → rapport texte avec tableau rĂ©capitulatif
         ├──→ BulkActionsViewModel.generateCsvContent()        → export CSV
         └──→ BulkActionsScreen.ResultItem()                   → affichage UI Compose (icîne + lignes)

Classes Clés

ClasseRĂŽle
BulkConfigParserAnalyse JSON en BulkConfig data class
BulkActionsRepository.executeSingleCommand()Dispatche chaque mot-clé de commande vers l'exécuteur correct
executePing() 
 executeLanScan()9 exĂ©cuteurs privĂ©s — invoquent les dĂ©pĂŽts ou binaires systĂšme
BulkCommandResult (+ sous-classes)Hiérarchie scellée représentant les résultats d'exécution
BulkActionsViewModel.generateOutputContent()Formate les résultats en rapport texte avec tableau récapitulatif
BulkActionsViewModel.generateCsvContent()Formate les résultats en CSV
BulkActionsScreen.ResultItem()Affiche chaque résultat dans l'UI Compose (icÎne + statut + lignes de sortie)

MIT 2026 © Nextra.