Allowed entries: # Rscript -e expr # Rscript path/to/file
(entry: list[str])
| 155 | |
| 156 | |
| 157 | def _entry_validate(entry: list[str]) -> None: |
| 158 | """ |
| 159 | Allowed entries: |
| 160 | # Rscript -e expr |
| 161 | # Rscript path/to/file |
| 162 | """ |
| 163 | if entry[0] != 'Rscript': |
| 164 | raise ValueError('entry must start with `Rscript`.') |
| 165 | |
| 166 | if entry[1] == '-e': |
| 167 | if len(entry) > 3: |
| 168 | raise ValueError('You can supply at most one expression.') |
| 169 | elif len(entry) > 2: |
| 170 | raise ValueError( |
| 171 | 'The only valid syntax is `Rscript -e {expr}`' |
| 172 | 'or `Rscript path/to/hook/script`', |
| 173 | ) |
| 174 | |
| 175 | |
| 176 | def _cmd_from_hook( |