shell dot on steroids https://pagure.io/shellfu

wrap_debug 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/bash
  2. . "$(sfpath)"
  3. shellfu import pretty
  4. #
  5. # These functions look like from modules
  6. #
  7. # Normally these functions would have to be defined in separate
  8. # files and imported using `shellfu import `, but for the sake
  9. # of testing it's OK to pretend a bit.
  10. #
  11. # Note that they also follow the notation of demarking internal
  12. # functions by single or double underscore.
  13. #
  14. #
  15. # Look like from foomod
  16. #
  17. foomod__room() {
  18. debug "in a room"
  19. foomod__desk
  20. }
  21. foomod__desk() {
  22. debug "in a desk"
  23. foomod__drawer
  24. }
  25. foomod__drawer() {
  26. debug "in a drawer"
  27. _foomod__box
  28. }
  29. _foomod__box() {
  30. debug "in a secret box"
  31. __foomod__document
  32. }
  33. __foomod__document() {
  34. debug "in a secret document"
  35. barmod__page
  36. }
  37. #
  38. # Look like from barmod
  39. #
  40. barmod__page() {
  41. debug "on a page"
  42. barmod__paragraph
  43. }
  44. barmod__paragraph() {
  45. debug "in a paragraph"
  46. barmod__sentence
  47. }
  48. barmod__sentence() {
  49. debug "in a sentence"
  50. _barmod__word
  51. }
  52. _barmod__word() {
  53. debug "in an unknown word"
  54. __barmod__letter
  55. }
  56. __barmod__letter() {
  57. debug "is an unknown letter"
  58. }
  59. #
  60. # Look like defined here
  61. #
  62. # No particular convention is required for scripts; these functions
  63. # should "look local".
  64. #
  65. # Note that debug from main() will appear as if directly from the script
  66. # main body, not the function. As bash reports FUNCNAME as `main` for
  67. # code that is not in any function, this cannot be changed.
  68. #
  69. __really_do_process_task() {
  70. debug "totally really starting the task"
  71. foomod__room
  72. }
  73. __do_process_task() {
  74. debug "really starting the task"
  75. __really_do_process_task
  76. }
  77. process_task() {
  78. debug "about to do a task"
  79. __do_process_task
  80. }
  81. process_job() {
  82. debug "in house"
  83. process_task
  84. }
  85. main() {
  86. debug "just poking about"
  87. process_job
  88. }
  89. main "$@"