mad.htm 2.3 KB

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