mad.htm 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>MAD</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
  2. <a href="https://n2o.dev">DEV</a>
  3. <a href="https://mad.n2o.space">MAD</a>
  4. <a href="#" style="background:#ededed;">MAD</a>
  5. </nav><header>
  6. <a href="../index.html"><img src="https://n2o.space/img/Synrc Neo.svg" /></a>
  7. <h1>MAD</h1>
  8. </header><main>
  9. <section>
  10. <h3>INTRO</h3>
  11. <p>MAD module provides user level interface for console commands.</p>
  12. <p></p><blockquote><p></p><ul><li><b><a href="#main">main/1</a></b> — IO parameters.</li><li><b><a href="#help">help/0</a></b> — Display help.</li><li><b><a href="#profile">profile/0</a></b> — Current MAD profile.</li><li><b><a href="#atomize">atomize/1</a></b> — Commands mappings.</li></ul></blockquote>
  13. </section>
  14. <section>
  15. <h3>PROFILE</h3>
  16. <p>Each MAD profile must imeplent exposed API:</p>
  17. <figure><code>
  18. -define(MAD,[compile/1,app/1,get/1,release/1,resolve/1,clean/1,
  19. start/1,attach/1,stop/1,sh/1,deps/1,up/1,fetch/1,
  20. static/1,eunit/1,strip/1]).
  21. </code></figure>
  22. <figure><code>
  23. -type return() :: [] | {ok,any()} | {error,any()}.
  24. </code></figure>
  25. <p>Each function from exposed API has same signature from list of string
  26. to sum of nil and error protocols.</p>
  27. <h4>compile(list(string())) -> return().</h4>
  28. <h4>app(list(string())) -> return().</h4>
  29. <h4>get(list(string())) -> return().</h4>
  30. <h4>release(list(string())) -> return().</h4>
  31. <h4>clean(list(string())) -> return().</h4>
  32. <h4>start(list(string())) -> return().</h4>
  33. <h4>stop(list(string())) -> return().</h4>
  34. <h4>sh(list(string())) -> return().</h4>
  35. <h4>deps(list(string())) -> return().</h4>
  36. <h4>up(list(string())) -> return().</h4>
  37. <h4>sh(list(string())) -> return().</h4>
  38. <h4>fetch(list(string())) -> return().</h4>
  39. <h4>static(list(string())) -> return().</h4>
  40. <h4>eunit(list(string())) -> return().</h4>
  41. <h4>strip(list(string())) -> return().</h4>
  42. </section>
  43. <section>
  44. <h3>LOOP</h3>
  45. <h4>main(list(string())) -> integer().</h4>
  46. <p>Simple yet understandable command processing and error loop.
  47. Function <b>atomize/1</b> helps to accumulate
  48. known agruments as atoms. Function <b>profile/0</b>
  49. retrives module with MAD API implementation.
  50. <b>main/1</b> function returns error status to OS with halt.</p>
  51. <figure><code>
  52. main(Params) ->
  53. { _Invalid, Valid } = lists:foldr(
  54. fun (X,{C,R}) when is_atom(X) -> {[],[{X,C}|R]};
  55. (X,{C,R}) -> {[X|C],R}
  56. end, {[],[]}, lists:map(fun atomize/1, Params)),
  57. halt(return(
  58. lists:any(fun({error,X}) -> mad:info("~s~n",[X]), true;
  59. (_) -> false end,
  60. lists:flatten([
  61. lists:foldl(
  62. fun ({Fun,Arg},ErrAcc) ->
  63. mad_hooks:run_hooks(pre, Fun),
  64. Errors = errors((profile()):Fun(Arg)),
  65. mad_hooks:run_hooks(post, Fun),
  66. Errors ++ ErrAcc
  67. end, [], Valid)])))).
  68. </code></figure>
  69. </section>
  70. <section>
  71. <p>This module may refer to:
  72. <a href="mad_local.htm"><b>mad_local</b></a>.
  73. </p>
  74. </section>
  75. </main><footer>
  76. 2005—2018 © Synrc Research Center
  77. </footer></body></html>