idea--thule-alternatives 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. id: 'idea--thule-alternatives'
  2. content: |
  3. The big alternative I know of is
  4. [termkit](https://github.com/unconed/TermKit), which is an interesting
  5. experiment: but, to me, it's filled with far too many special cases
  6. and not enough nice primitives. For example, there's a special
  7. way of outputting a list of files (e.g. output from `ls`) but this
  8. isn't because "files" are necessarily a distinct thing, but because
  9. there's a special type of output for `ls`-like commands (in this
  10. case, `application/json; schema=termkit.files`, which corresponds
  11. to a list of filenames.)
  12. Thule builds on top of this by having a standard set of building
  13. blocks, so that you no longer have the special-case "list of files",
  14. but rather primitive building blocks like `list`s and `file`s.
  15. Consider the output from `wc`: this also contains file references,
  16. but it additionally contains a table mapping those to values. In
  17. a TermKit-like setting, you'd have to come up with a new schema
  18. (say, `application/json; schema=termkit.wordcount`) that understands
  19. which parts of the output are files and which aren't.
  20. Thule aims to pull those low-level building blocks out, so the
  21. output from `ls` might give you a collection like
  22. (set (file "/tmp/foo.txt") (file "/tmp/bar.c"))
  23. and the output from `wc` will give you
  24. (table ("lines" "words" "characters" "file")
  25. ((int 10) (int 30) (int 300) (file "/tmp/foo.txt"))
  26. ((int 20) (int 60) (int 900) (file "/tmp/bar.c"))
  27. ((int 30) (int 90) (int 1200) (text "total")))
  28. Both of these would not be displayed in a raw way by the shell, but
  29. rather the structure of the collections would be a hint to the
  30. shell on how to display them in a rich way.
  31. related:
  32. - name: idea--thule
  33. why: The high-level idea