github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/tabulate/tabulate_sd_test.go (about) 1 package tabulate 2 3 import ( 4 "testing" 5 6 "github.com/lmorg/murex/lang/types" 7 "github.com/lmorg/murex/test" 8 ) 9 10 var ( 11 inSd = `systemctl [OPTIONS...] COMMAND ... 12 13 Query or send control commands to the system manager. 14 15 Unit Commands: 16 list-units [PATTERN...] List units currently in memory 17 list-sockets [PATTERN...] List socket units currently in memory, 18 ordered by address 19 list-timers [PATTERN...] List timer units currently in memory, 20 ordered by next elapse 21 start UNIT... Start (activate) one or more units 22 stop UNIT... Stop (deactivate) one or more units 23 reload UNIT... Reload one or more units 24 restart UNIT... Start or restart one or more units 25 try-restart UNIT... Restart one or more units if active 26 reload-or-restart UNIT... Reload one or more units if possible, 27 otherwise start or restart 28 try-reload-or-restart UNIT... If active, reload one or more units, 29 if supported, otherwise restart 30 isolate UNIT Start one unit and stop all others 31 kill UNIT... Send signal to processes of a unit 32 clean UNIT... Clean runtime, cache, state, logs or 33 configuration of unit 34 freeze PATTERN... Freeze execution of unit processes 35 thaw PATTERN... Resume execution of a frozen unit 36 is-active PATTERN... Check whether units are active 37 is-failed PATTERN... Check whether units are failed 38 status [PATTERN...|PID...] Show runtime status of one or more units 39 show [PATTERN...|JOB...] Show properties of one or more 40 units/jobs or the manager 41 cat PATTERN... Show files and drop-ins of specified units 42 set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit 43 help PATTERN...|PID... Show manual for one or more units 44 reset-failed [PATTERN...] Reset failed state for all, one, or more 45 units 46 list-dependencies [UNIT...] Recursively show units which are required 47 or wanted by the units or by which those 48 units are required or wanted 49 Unit File Commands: 50 list-unit-files [PATTERN...] List installed unit files 51 enable [UNIT...|PATH...] Enable one or more unit files 52 disable UNIT... Disable one or more unit files 53 reenable UNIT... Reenable one or more unit files 54 preset UNIT... Enable/disable one or more unit files 55 based on preset configuration 56 preset-all Enable/disable all unit files based on 57 preset configuration 58 is-enabled UNIT... Check whether unit files are enabled 59 mask UNIT... Mask one or more units 60 unmask UNIT... Unmask one or more units 61 link PATH... Link one or more units files into 62 the search path 63 revert UNIT... Revert one or more unit files to vendor 64 version 65 add-wants TARGET UNIT... Add 'Wants' dependency for the target 66 on specified one or more units 67 add-requires TARGET UNIT... Add 'Requires' dependency for the target 68 on specified one or more units 69 edit UNIT... Edit one or more unit files 70 get-default Get the name of the default target 71 set-default TARGET Set the default target 72 73 Machine Commands: 74 list-machines [PATTERN...] List local containers and host 75 76 Job Commands: 77 list-jobs [PATTERN...] List jobs 78 cancel [JOB...] Cancel all, one, or more jobs 79 80 Environment Commands: 81 show-environment Dump environment 82 set-environment VARIABLE=VALUE... Set one or more environment variables 83 unset-environment VARIABLE... Unset one or more environment variables 84 import-environment [VARIABLE...] Import all or some environment variables 85 86 Manager State Commands: 87 daemon-reload Reload systemd manager configuration 88 daemon-reexec Reexecute systemd manager 89 log-level [LEVEL] Get/set logging threshold for manager 90 log-target [TARGET] Get/set logging target for manager 91 service-watchdogs [BOOL] Get/set service watchdog state 92 93 System Commands: 94 is-system-running Check whether system is fully running 95 default Enter system default mode 96 rescue Enter system rescue mode 97 emergency Enter system emergency mode 98 halt Shut down and halt the system 99 poweroff Shut down and power-off the system 100 reboot Shut down and reboot the system 101 kexec Shut down and reboot the system with kexec 102 exit [EXIT_CODE] Request user instance or container exit 103 switch-root ROOT [INIT] Change to a different root file system 104 suspend Suspend the system 105 hibernate Hibernate the system 106 hybrid-sleep Hibernate and suspend the system 107 suspend-then-hibernate Suspend the system, wake after a period of 108 time, and hibernate 109 Options: 110 -h --help Show this help 111 --version Show package version 112 --system Connect to system manager 113 --user Connect to user service manager 114 -H --host=[USER@]HOST Operate on remote host 115 -M --machine=CONTAINER Operate on a local container 116 -t --type=TYPE List units of a particular type 117 --state=STATE List units with particular LOAD or SUB or ACTIVE state 118 --failed Shortcut for --state=failed 119 -p --property=NAME Show only properties by this name 120 -P NAME Equivalent to --value --property=NAME 121 -a --all Show all properties/all units currently in memory, 122 including dead/empty ones. To list all units installed 123 on the system, use 'list-unit-files' instead. 124 -l --full Don't ellipsize unit names on output 125 -r --recursive Show unit list of host and local containers 126 --reverse Show reverse dependencies with 'list-dependencies' 127 --with-dependencies Show unit dependencies with 'status', 'cat', 128 'list-units', and 'list-unit-files'. 129 --job-mode=MODE Specify how to deal with already queued jobs, when 130 queueing a new job 131 -T --show-transaction When enqueuing a unit job, show full transaction 132 --show-types When showing sockets, explicitly show their type 133 --value When showing properties, only print the value 134 -i --ignore-inhibitors When shutting down or sleeping, ignore inhibitors 135 --kill-who=WHO Whom to send signal to 136 -s --signal=SIGNAL Which signal to send 137 --what=RESOURCES Which types of resources to remove 138 --now Start or stop unit after enabling or disabling it 139 --dry-run Only print what would be done 140 Currently supported by verbs: halt, poweroff, reboot, 141 kexec, suspend, hibernate, suspend-then-hibernate, 142 hybrid-sleep, default, rescue, emergency, and exit. 143 -q --quiet Suppress output 144 --wait For (re)start, wait until service stopped again 145 For is-system-running, wait until startup is completed 146 --no-block Do not wait until operation finished 147 --no-wall Don't send wall message before halt/power-off/reboot 148 --no-reload Don't reload daemon after en-/dis-abling unit files 149 --no-legend Do not print a legend (column headers and hints) 150 --no-pager Do not pipe output into a pager 151 --no-ask-password Do not ask for system passwords 152 --global Enable/disable/mask unit files globally 153 --runtime Enable/disable/mask unit files temporarily until next 154 reboot 155 -f --force When enabling unit files, override existing symlinks 156 When shutting down, execute action immediately 157 --preset-mode= Apply only enable, only disable, or all presets 158 --root=PATH Enable/disable/mask unit files in the specified root 159 directory 160 -n --lines=INTEGER Number of journal entries to show 161 -o --output=STRING Change journal output mode (short, short-precise, 162 short-iso, short-iso-precise, short-full, 163 short-monotonic, short-unix, 164 verbose, export, json, json-pretty, json-sse, cat) 165 --firmware-setup Tell the firmware to show the setup menu on next boot 166 --boot-loader-menu=TIME 167 Boot into boot loader menu on next boot 168 --boot-loader-entry=NAME 169 Boot into a specific boot loader entry on next boot 170 --plain Print unit dependencies as a list instead of a tree 171 172 See the systemctl(1) man page for details. 173 ` 174 175 jsonSd = `{"--all":"Show all properties/all units currently in memory, including dead/empty ones. To list all units installed on the system, use 'list-unit-files' instead.","--boot-loader-entry=":"(args: NAME) Boot into a specific boot loader entry on next boot","--boot-loader-menu=":"(args: TIME) Boot into boot loader menu on next boot","--dry-run":"Only print what would be done Currently supported by verbs: halt, poweroff, reboot, kexec, suspend, hibernate, suspend-then-hibernate, hybrid-sleep, default, rescue, emergency, and exit.","--failed":"Shortcut for --state=failed","--firmware-setup":"Tell the firmware to show the setup menu on next boot","--force":"When enabling unit files, override existing symlinks When shutting down, execute action immediately","--full":"Don't ellipsize unit names on output","--global":"Enable/disable/mask unit files globally","--help":"Show this help","--host=":"(args: [USER@]HOST) Operate on remote host","--ignore-inhibitors":"(args: When shutting down or sleeping, ignore inhibitors) ","--job-mode=":"(args: MODE) Specify how to deal with already queued jobs, when queueing a new job","--kill-who=":"(args: WHO) Whom to send signal to","--lines=":"(args: INTEGER) Number of journal entries to show","--machine=":"(args: Operate on a local container) ","--no-ask-password":"Do not ask for system passwords","--no-block":"Do not wait until operation finished","--no-legend":"Do not print a legend (column headers and hints)","--no-pager":"Do not pipe output into a pager","--no-reload":"Don't reload daemon after en-/dis-abling unit files","--no-wall":"Don't send wall message before halt/power-off/reboot","--now":"Start or stop unit after enabling or disabling it","--output=":"(args: STRING) Change journal output mode (short, short-precise, short-iso, short-iso-precise, short-full, short-monotonic, short-unix, verbose, export, json, json-pretty, json-sse, cat)","--plain":"Print unit dependencies as a list instead of a tree","--preset-mode=":"Apply only enable, only disable, or all presets","--property=":"(args: NAME) Show only properties by this name","--quiet":"Suppress output","--recursive":"Show unit list of host and local containers","--reverse":"Show reverse dependencies with 'list-dependencies'","--root=":"(args: PATH) Enable/disable/mask unit files in the specified root directory","--runtime":"Enable/disable/mask unit files temporarily until next reboot","--show-transaction":"When enqueuing a unit job, show full transaction","--show-types":"When showing sockets, explicitly show their type","--signal=":"(args: SIGNAL) Which signal to send","--state=":"(args: STATE) List units with particular LOAD or SUB or ACTIVE state","--system":"Connect to system manager","--type=":"(args: TYPE) List units of a particular type","--user":"Connect to user service manager","--value":"When showing properties, only print the value","--version":"Show package version","--wait":"For (re)start, wait until service stopped again For is-system-running, wait until startup is completed","--what=":"(args: RESOURCES) Which types of resources to remove","--with-dependencies":"(args: Show unit dependencies with 'status', 'cat',) 'list-units', and 'list-unit-files'.","-H":"(args: [USER@]HOST) Operate on remote host","-M":"(args: Operate on a local container) ","-P":"(args: NAME) Equivalent to --value --property=NAME","-T":"When enqueuing a unit job, show full transaction","-a":"Show all properties/all units currently in memory, including dead/empty ones. To list all units installed on the system, use 'list-unit-files' instead.","-f":"When enabling unit files, override existing symlinks When shutting down, execute action immediately","-h":"Show this help","-i":"(args: When shutting down or sleeping, ignore inhibitors) ","-l":"Don't ellipsize unit names on output","-n":"(args: INTEGER) Number of journal entries to show","-o":"(args: STRING) Change journal output mode (short, short-precise, short-iso, short-iso-precise, short-full, short-monotonic, short-unix, verbose, export, json, json-pretty, json-sse, cat)","-p":"(args: NAME) Show only properties by this name","-q":"Suppress output","-r":"Show unit list of host and local containers","-s":"(args: SIGNAL) Which signal to send","-t":"(args: TYPE) List units of a particular type","add-requires":"(args: TARGET UNIT...) Add 'Requires' dependency for the target on specified one or more units","add-wants":"(args: TARGET UNIT...) Add 'Wants' dependency for the target on specified one or more units","cancel":"(args: [JOB...]) Cancel all, one, or more jobs","cat":"(args: PATTERN...) Show files and drop-ins of specified units set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit","clean":"(args: UNIT...) Clean runtime, cache, state, logs or configuration of unit","daemon-reexec":"Reexecute systemd manager","daemon-reload":"Reload systemd manager configuration","default":"Enter system default mode","disable":"(args: UNIT...) Disable one or more unit files","edit":"(args: UNIT...) Edit one or more unit files","emergency":"Enter system emergency mode","enable":"(args: [UNIT...|PATH...]) Enable one or more unit files","exit":"(args: [EXIT_CODE]) Request user instance or container exit","freeze":"(args: PATTERN...) Freeze execution of unit processes","get-default":"Get the name of the default target","halt":"Shut down and halt the system","help":"(args: PATTERN...|PID...) Show manual for one or more units","hibernate":"Hibernate the system","hybrid-sleep":"Hibernate and suspend the system","import-environment":"(args: [VARIABLE...]) Import all or some environment variables","is-active":"(args: PATTERN...) Check whether units are active","is-enabled":"(args: UNIT...) Check whether unit files are enabled","is-failed":"(args: PATTERN...) Check whether units are failed","is-system-running":"Check whether system is fully running","isolate":"(args: UNIT) Start one unit and stop all others","kexec":"Shut down and reboot the system with kexec","kill":"(args: UNIT...) Send signal to processes of a unit","link":"(args: PATH...) Link one or more units files into the search path","list-dependencies":"(args: [UNIT...]) Recursively show units which are required or wanted by the units or by which those units are required or wanted","list-jobs":"(args: [PATTERN...]) List jobs","list-machines":"(args: [PATTERN...]) List local containers and host","list-sockets":"(args: [PATTERN...]) List socket units currently in memory, ordered by address","list-timers":"(args: [PATTERN...]) List timer units currently in memory, ordered by next elapse","list-unit-files":"(args: [PATTERN...]) List installed unit files","list-units":"(args: [PATTERN...]) List units currently in memory","log-level":"(args: [LEVEL]) Get/set logging threshold for manager","log-target":"(args: [TARGET]) Get/set logging target for manager","mask":"(args: UNIT...) Mask one or more units","poweroff":"Shut down and power-off the system","preset":"(args: UNIT...) Enable/disable one or more unit files based on preset configuration","preset-all":"Enable/disable all unit files based on preset configuration","reboot":"Shut down and reboot the system","reenable":"(args: UNIT...) Reenable one or more unit files","reload":"(args: UNIT...) Reload one or more units","reload-or-restart":"(args: UNIT...) Reload one or more units if possible, otherwise start or restart","rescue":"Enter system rescue mode","reset-failed":"(args: [PATTERN...]) Reset failed state for all, one, or more units","restart":"(args: UNIT...) Start or restart one or more units","revert":"(args: UNIT...) Revert one or more unit files to vendor version","service-watchdogs":"(args: [BOOL]) Get/set service watchdog state","set-default":"(args: TARGET) Set the default target","set-environment":"(args: VARIABLE=VALUE...) Set one or more environment variables","show":"(args: [PATTERN...|JOB...]) Show properties of one or more units/jobs or the manager","show-environment":"Dump environment","start":"(args: UNIT...) Start (activate) one or more units","status":"(args: [PATTERN...|PID...]) Show runtime status of one or more units","stop":"(args: UNIT...) Stop (deactivate) one or more units","suspend":"Suspend the system","suspend-then-hibernate":"Suspend the system, wake after a period of time, and hibernate","switch-root":"(args: [INIT]) Change to a different root file system","thaw":"(args: PATTERN...) Resume execution of a frozen unit","try-reload-or-restart":"(args: UNIT...) If active, reload one or more units, if supported, otherwise restart","try-restart":"(args: UNIT...) Restart one or more units if active","unmask":"(args: UNIT...) Unmask one or more units","unset-environment":"(args: VARIABLE...) Unset one or more environment variables"}` 176 ) 177 178 func TestTabulateSystemD(t *testing.T) { 179 test.RunMethodTest(t, 180 cmdTabulate, "tabulate", 181 inSd, 182 types.Generic, 183 []string{fMap, fKeyIncHint, fSplitSpace, fColumnWraps}, 184 jsonSd, 185 nil, 186 ) 187 }