github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/integrations/systemctl_linux.mx (about)

     1  !if { which: systemctl } then {
     2      return
     3  }
     4  
     5  private autocomplete.systemctl {
     6      # Returns all known systemd unit files
     7      systemctl: list-unit-files -> !regexp m/unit files listed/ -> [:0] -> cast str
     8  }
     9  
    10  test unit private autocomplete.systemctl %{
    11      StdoutRegex: '(shutdown\.target)'
    12      StdoutType:  str
    13      StdoutGreaterThan: 1
    14      StdoutIsArray: true
    15  }
    16  
    17  function autocomplete.systemctl.flags {
    18      # Parses `systemctl --help` looking for flags then returns `autocomplete` config based on those flags
    19      systemctl: --help -> regexp %(m/PATTERN/) -> tabulate: --map --key-inc-hint -> formap key val {
    20          out ("$key": [{
    21              "Dynamic": ({ autocomplete.systemctl }),
    22              "ListView": true,
    23              "Optional": false,
    24              "AllowMultiple": true
    25          }],)
    26      }
    27      out ("": [{}]) # dummy value so there's no trailing comma
    28  }
    29  
    30  autocomplete set systemctl ([
    31      {
    32          "DynamicDesc": ({
    33              systemctl: --help -> @[..Unit Commands:]s -> tabulate: --column-wraps --map --key-inc-hint --split-space
    34          }),
    35          "Optional": true,
    36          "AllowMultiple": false
    37      },
    38      {
    39          "DynamicDesc": ({
    40              systemctl: --help -> @[Unit Commands:..]s -> tabulate: --column-wraps --map --key-inc-hint
    41          }),
    42          "Optional": false,
    43          "AllowMultiple": false,
    44          "FlagValues": {
    45              ${ autocomplete.systemctl.flags }
    46          }
    47      }
    48  ])
    49  
    50  !function autocomplete.systemctl.flags