|
| 1 | +LKQL Driver |
| 2 | +=========== |
| 3 | + |
| 4 | +Additionally to the ``gnatcheck`` executable, you can access the LKQL language |
| 5 | +through the LKQL driver. This is an executable file named ``lkql`` which |
| 6 | +defines several sub-commands, each being an entry point to the LKQL engine. |
| 7 | + |
| 8 | +.. attention:: |
| 9 | + |
| 10 | + While being shipped alongside GNATcheck, not all sub-commands are considered |
| 11 | + as stable, some are even experimental or internal and should be used with |
| 12 | + extreme caution. |
| 13 | + |
| 14 | +.. _Sub_commands_List: |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +Sub-commands List |
| 19 | +----------------- |
| 20 | + |
| 21 | +Additionally to their specific switches, each sub-command accepts the |
| 22 | +``--help`` flag which triggers the display of its specific help message and |
| 23 | +exit. |
| 24 | + |
| 25 | + |
| 26 | +``lkql refactor`` |
| 27 | +^^^^^^^^^^^^^^^^^ |
| 28 | + |
| 29 | +.. hint:: |
| 30 | + |
| 31 | + This sub-command is considered as stable and is officially supported. |
| 32 | + |
| 33 | +This sub-command is used to perform automatic refactoring operations. It is |
| 34 | +mainly used to automatically migrate existing LKQL code-bases when a change is |
| 35 | +made in the language syntax or sematic. |
| 36 | + |
| 37 | +``refactor`` defines the following CLI switches: |
| 38 | + |
| 39 | +``-i, --in-place`` |
| 40 | + Apply refactoring directly into LKQL source files, modifying them. |
| 41 | + |
| 42 | +``-r, --refactoring=<refactoring>`` |
| 43 | + Name of the refactoring to apply to your LKQL files. You can view a list of |
| 44 | + available refactorings in the sub-command help message. |
| 45 | + |
| 46 | +Additionally to those switches, the ``refactor`` sub-command expect a list of |
| 47 | +LKQL files to apply the specified refactoring on. Here is an example usage: |
| 48 | + |
| 49 | +.. code-block:: |
| 50 | +
|
| 51 | + lkql refactor -i -r=IS_TO_COLON file_1.lkql file_2.lkql |
| 52 | +
|
| 53 | +
|
| 54 | +``lkql run`` |
| 55 | +^^^^^^^^^^^^ |
| 56 | + |
| 57 | +.. caution:: |
| 58 | + |
| 59 | + This sub-command is considered as a beta feature: while being pretty stable, |
| 60 | + its interface may change in the future, and relying on it should be |
| 61 | + considered as unsafe. |
| 62 | + |
| 63 | +This is the LKQL interpreter entry point, through it you can access the current |
| 64 | +LKQL implementation to run any LKQL script or start a REPL. This is a good |
| 65 | +entry point to test the LKQL language and write custom GNATcheck rules in an |
| 66 | +iterative way. |
| 67 | + |
| 68 | +``run`` defines the following CLI switches: |
| 69 | + |
| 70 | +``-C, --charset=<charset>`` |
| 71 | + Defines the charset to use for source decoding. The default is "utf-8". |
| 72 | + |
| 73 | +``-i, --interactive`` |
| 74 | + Start an LKQL REPL (read-eval-print loop). This switch is incompatible with |
| 75 | + the ``-S, --script-path`` one. |
| 76 | + |
| 77 | +``--keep-going-on-missing-file`` |
| 78 | + Don't stop the interpreter if an Ada source file is missing, just print a |
| 79 | + warning message instead. |
| 80 | + |
| 81 | +``-P, --project=<project>`` |
| 82 | + GPR file to fetch Ada sources from for the interpreter. |
| 83 | + |
| 84 | +``--RTS=<runtime>`` |
| 85 | + Ada runtime to use when resolving sources. |
| 86 | + |
| 87 | +``-S, --script-path=<script>`` |
| 88 | + Name of the LKQL script to run. This switch is incompatible with the |
| 89 | + ``-i, --interactive`` one. |
| 90 | + |
| 91 | +``--target=<target>`` |
| 92 | + Hardware target used to resolved Ada runtime sources. |
| 93 | + |
| 94 | +``-U, --recursive`` |
| 95 | + Process all units in the project tree, excluding externally built project. |
| 96 | + |
| 97 | +``-v, --verbose`` |
| 98 | + Enable the verbose mode. |
| 99 | + |
| 100 | +Additionally to those switches, you can provide to the ``run`` sub-command a |
| 101 | +list of Ada sources to use. Here is an example usage: |
| 102 | + |
| 103 | +.. code-block:: |
| 104 | +
|
| 105 | + lkql run --keep-going-on-missing-file -S script.lkql main.adb |
| 106 | +
|
| 107 | +
|
| 108 | +``lkql check`` |
| 109 | +^^^^^^^^^^^^^^ |
| 110 | + |
| 111 | +.. danger:: |
| 112 | + |
| 113 | + This sub-command is considered as unstable and is not supported. Use it at |
| 114 | + your own risks. |
| 115 | + |
| 116 | +This sub-command is used to run a set of LKQL rules on provided Ada sources. |
| 117 | +This is an internal entry point mainly used to test GNATcheck rules. |
| 118 | + |
| 119 | +``check`` defines the following CLI switches: |
| 120 | + |
| 121 | +``-C, --charset=<charset>`` |
| 122 | + Defines the charset to use for source decoding. The default is "utf-8". |
| 123 | + |
| 124 | +``-j, --jobs=<n>`` |
| 125 | + Number of jobs to use during analysis. If n is 0, spawn 1 job per CPU. |
| 126 | + |
| 127 | +``-P, --project=<project>`` |
| 128 | + GPR file to fetch Ada sources from for the interpreter. |
| 129 | + |
| 130 | +``--RTS=<runtime>`` |
| 131 | + Ada runtime to use when resolving sources. |
| 132 | + |
| 133 | +``--target=<target>`` |
| 134 | + Hardware target used to resolved Ada runtime sources. |
| 135 | + |
| 136 | +``-U, --recursive`` |
| 137 | + Process all units in the project tree, excluding externally built project. |
| 138 | + |
| 139 | +``-v, --verbose`` |
| 140 | + Enable the verbose mode. |
| 141 | + |
| 142 | + |
| 143 | +``-r, --rule=<rule>`` |
| 144 | + Enable the given rule for the current run. This option is cumulative. |
| 145 | + |
| 146 | +``--rules-dir=<directory>`` |
| 147 | + Additional directory to fetch LKQL rules from. This options is cumulative. |
| 148 | + |
| 149 | +``-a, --rule-arg=<rule>.<arg>=<value>`` |
| 150 | + Provide a value for a specific argument of a rule. This option is cumulative. |
| 151 | + |
| 152 | +Additionally to those switches, you can provide to the ``check`` sub-command a |
| 153 | +list of Ada sources to use during analysis. Here is an example usage: |
| 154 | + |
| 155 | +.. code-block:: |
| 156 | +
|
| 157 | + lkql check main.adb main.ads -r my_rule -a "my_rule.arg=42" |
| 158 | +
|
| 159 | +
|
| 160 | +``lkql fix`` |
| 161 | + |
| 162 | +.. danger:: |
| 163 | + |
| 164 | + This sub-command is considered as an experimental feature. Use it at your |
| 165 | + own risks. |
| 166 | + |
| 167 | +Sub-command to run a set of auto-fixing functions on a set of sources. This is |
| 168 | +an experimental entry point mainly used for testing purposes, but you can give |
| 169 | +it a try (be careful, this process may alter your Ada sources). |
| 170 | + |
| 171 | +``fix`` defines the same switches as ``lkql check`` sub-command, with some |
| 172 | +additional ones: |
| 173 | + |
| 174 | +``--auto-fix-mode=<mode>`` |
| 175 | + The mode to use when applying auto-fixes. Available modes are: |
| 176 | + * ``DISPLAY``: Only display fixed sources in standard output, doesn't modify |
| 177 | + any source file |
| 178 | + * ``NEW_FILE``: For each source file, if it has some fixes, create a new file |
| 179 | + named ``<filename>.patched`` alongside the original one containing the |
| 180 | + patched source |
| 181 | + * ``PATH_FILE``: Replace each source file that has fixes in them by their |
| 182 | + patched version |
| 183 | + |
| 184 | +For now, there is no list of rules with an auto-fix function, but you can check |
| 185 | +if a rule can be used with this sub-command by reading its source code and |
| 186 | +checking for the ``auto_fix`` argument in its related ``@check`` annotation. |
| 187 | + |
| 188 | + |
| 189 | +``lkql doc-api`` |
| 190 | +^^^^^^^^^^^^^^^^ |
| 191 | + |
| 192 | +.. danger:: |
| 193 | + |
| 194 | + This sub-command is considered as unstable and is not supported. Use it at |
| 195 | + your own risks. |
| 196 | + |
| 197 | +Entry point used to generate API documentation for LKQL modules in the RST |
| 198 | +format. Each LKQL file defines a module and all top level symbols are |
| 199 | +documented. |
| 200 | + |
| 201 | +``doc-api`` defines the following CLI switches: |
| 202 | + |
| 203 | +``-O, --output-dir=<directory>`` |
| 204 | + Directory path to place generated RST files in. |
| 205 | + |
| 206 | +``--std`` |
| 207 | + Additionally to other generated files, generate the documentation of the LKQL |
| 208 | + prelude and built-in functions. |
| 209 | + |
| 210 | +Additionally to those switches, the ``doc-api`` sub-command expect a list of |
| 211 | +LKQL files to generate documentation for. Here is an example usage: |
| 212 | + |
| 213 | +.. code-block:: |
| 214 | +
|
| 215 | + lkql doc-api -O=doc/ --std file_1.lkql file_2.lkql |
| 216 | +
|
| 217 | +
|
| 218 | +``lkql doc-rules`` |
| 219 | +^^^^^^^^^^^^^^^^^^ |
| 220 | + |
| 221 | +.. danger:: |
| 222 | + |
| 223 | + This sub-command is considered as unstable and is not supported. Moreover, |
| 224 | + some information are hard-coded in it, so it should be considered as an |
| 225 | + internal. Use it at your own risks. |
| 226 | + |
| 227 | +Entry point used to generate documentation for a set of LKQL rules in the RST |
| 228 | +format. |
| 229 | + |
| 230 | +``doc-rules`` defines the following CLI switches: |
| 231 | + |
| 232 | +``-O, --output-dir=<directory>`` |
| 233 | + Directory path to place generated RST files in. |
| 234 | + |
| 235 | +``-v, --verbose`` |
| 236 | + Enable the verbose mode. |
| 237 | + |
| 238 | +This sub-command also expect a list of directories containing LKQL rules to |
| 239 | +generate the documentation for. Here is an example usage: |
| 240 | + |
| 241 | +.. code-block:: |
| 242 | +
|
| 243 | + lkql doc-rules -O=rules_doc/ rules/ other_rules/ |
| 244 | +
|
| 245 | +
|
| 246 | +``lkql gnatcheck_worker`` |
| 247 | +^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 248 | + |
| 249 | +.. danger:: |
| 250 | + |
| 251 | + This sub-command is considered as internal and is not meant to be used from |
| 252 | + the command-line. |
| 253 | + |
| 254 | +This is the entry point of the GNATcheck driver, and it is not meant to be used |
| 255 | +outside this context. That's why this entry point won't be documented any |
| 256 | +further. |
0 commit comments