idea--thule-alternatives 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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` and `file`.
  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. This is
  20. particularly tricky for `wc`, because you want to have the
  21. final `total` row, which does _not_ contain a file. And what if
  22. other tools also print table-like structures? Can those be
  23. processed with the same tools?
  24. Thule aims to pull those low-level building blocks out, so the
  25. output from `ls` might give you a collection like
  26. (set (file "/tmp/foo.txt") (file "/tmp/bar.c"))
  27. and the output from `wc` will give you
  28. (table ((text "lines") (text "words") (text "characters") (text "file"))
  29. ((int 10) (int 30) (int 300) (file "/tmp/foo.txt"))
  30. ((int 20) (int 60) (int 900) (file "/tmp/bar.c"))
  31. ((int 30) (int 90) (int 1200) (text "total")))
  32. rather the structure of the collections would be a hint to the
  33. shell on how to display them in a rich way.
  34. related:
  35. - name: idea--thule
  36. why: The high-level idea