iganaq/ocaml
2025-05-17 06:50:36 -03:00
..
bin OCaml: Implement Writer monad 2025-05-16 02:51:33 -03:00
lib OCaml: Add simulate (dry run) configuration option 2025-05-17 00:54:18 -03:00
test OCaml: Add tests for su_command default fallback 2025-05-17 00:54:29 -03:00
.gitignore Scaffold OCaml project 2025-03-31 10:09:43 -03:00
.justfile OCaml: Minor justfile tweaks 2025-05-17 02:24:26 -03:00
.ocamlformat OCaml: Apply formatting 2025-04-19 19:09:16 -03:00
.ocamlformat-ignore OCaml: Apply formatting 2025-04-19 19:09:16 -03:00
dune-project OCaml: Do not specify Dune version in dune-project 2025-04-15 20:57:21 -03:00
dune-workspace OCaml: Implement log contexts 2025-05-16 22:53:33 -03:00
README.md OCaml: Add references on ISO 14977:1996 EBNF downsides 2025-05-17 06:50:36 -03:00
tori.opam OCaml: Do not specify Dune version in dune-project 2025-04-15 20:57:21 -03:00

iganaq OCaml

This is the OCaml implementation of the iganaq prototype. See the root README for the general description.

Configuration parser

Grammar v0.2:

assignment  = { space }, key, { space }, equal, [ space ], value
key         = letter, { letter | digit | "_" }, equal
value       = valuable, { " " | valuable }, break
valuable    = ( letter | digit | "_" | "-" | "~" | "/" ), { valuable }
equal       = "="
break       = "\n"
space       = " " | "\t"

Written using the ISO 14977 EBNF Notation.

In this grammar, digit implies decimal digit. Spaces between the key and the = operator are lexed but meaningless. The first space after the = operator is parsed but meaningless. Additional spaces between the first space after the = operator and the first non-space character of the value are lexed and considered as part of the value. Spaces before the key and after the last non-space character until the newline are not lexed.

  • Note: non-terminals key and value are ambiguous.
    • Resolved by specifying what character terminates each

Task list

  • Spec requirements

    • Add log function
      • Output begins with [log]
      • Only prints if DEBUG is set
    • Get su command from $XDG_CONFIG_HOME/tori/tori.conf
      • Default to su -c
        • Handle fatal Sys_error if tori.conf doesn't exist
        • Handle checking su -c default with which when tori.conf exists but su_command is absent in it
        • Properly handle a compose su_command such as su -c in System.Package
        • Properly handle dependent options
        • Implement log levels
        • Write tests
      • Validation
        • Valid path or in PATH
        • Executability
        • true exits with status 01
    • Add logging
      • Logs only if DEBUG is set
      • Print each command executed, not just package names
    • Case with no packages provided
      • Prints a message
      • MUST NOT run any system commands
    • Unrecognized command: exit code 1
    • Command user: print the output of whoami
    • Command os: print the OS name
      • log the contents of /etc/os-release2
  • Incrementals

    • Simplify and analyze System.File
    • Simplify Reader
  • Additionals

    • Create remaining interface files
    • Expand unit tests coverage
    • Add interactive pkg tests (INS3 v0 B2.54)
    • Try out doc generation
    • Detect su_command from PATH before falling back to su
    • Raise on duplicate keys, currently shadowing
  • Check out

References

Notes


  1. INS v0 A3.4 "running 'true' with exit code 0" requires the user to input their password every time. This was dropped in INS v0.2, where "run 'true' with exit code 0" was removed from A3.4 ↩︎

  2. INS v0.1 changes requirement B2.3 to "MUST print the OS name and MUST log contents of /etc/os-release" in order to make the logging function testable without user input ↩︎

  3. INS, Iganaq Napkin Spec: https://brew.bsd.cafe/tori/iganaq#specification ↩︎

  4. INS v0 B2.5 "MUST NOT run any system commands" is only testable if we wrap command execution properly in e.g. a monad or list containing all executed commands, ensuring no command is ever executed without being appended to it ↩︎