OCaml: Only print log messages if DEBUG is set in the environment

Satisfies specification item A2
This commit is contained in:
Juno Takano 2025-04-21 20:10:59 -03:00
commit fab9c7140d
2 changed files with 12 additions and 9 deletions

View file

@ -1,14 +1,14 @@
- [ ] Spec requirements integration test coverage
- [x] Add log function
- [x] Output begins with ` [log] `
- [ ] Only prints if `DEBUG` is set
- [x] Only prints if `DEBUG` is set
- [ ] Add interactive pkg tests (INS v0 B2.5)
- [ ] Get su command from `$XDG_CONFIG_HOME/tori/tori.conf`
- [ ] Default to `su -c`
- [ ] Validation
- [ ] Valid path or in `PATH`
- [ ] Executability
- [ ] `true` exits with status 0
- [-] `true` exits with status 0 (see note 3)
- [x] Add logging
- [x] Print each command executed, not just package names
- [x] Case with no packages provided
@ -28,9 +28,9 @@
## Notes
- INS = Iganaq Napkin Spec: <https://brew.bsd.cafe/tori/iganaq#specification>
- INS v0 B2.5 "MUST NOT run any system commands" is only testable if we wrap
command execution properly in e.g. a list containing all executed commands
and ensure no command is ever executed without being appended to it
- INS v0 A3.4 "running 'true' with exit code 0" requires the user to input
their password every time. This should be dropped from the spec instead
1. INS = Iganaq Napkin Spec: <https://brew.bsd.cafe/tori/iganaq#specification>
2. INS v0 B2.5 "MUST NOT run any system commands" is only testable if we wrap
command execution properly in e.g. a list containing all executed commands
and ensure no command is ever executed without being appended to it
3. INS v0 A3.4 "running 'true' with exit code 0" requires the user to input
their password every time. This should be dropped from the spec instead

View file

@ -1 +1,4 @@
let elog message = prerr_endline @@ " [log] " ^ message
let elog (message : string) : unit =
let debug_flag = try Unix.getenv "DEBUG" with Not_found -> "" in
if debug_flag <> "" then prerr_endline @@ " [log] " ^ message