123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <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://n2o.dev/blank.css" />
- <link rel="stylesheet" href="https://n2o.dev/zima.css" />
- </head><body><nav>
- <a href="https://n2o.dev">DEV</a>
- <a href="../index.html">MAD</a>
- <a href="#" style="background:#ededed;">API</a>
- <div class="dropdown">
- <a onclick="drop()" class="dropbtn">EN</a>
- <div id="dropdown" class="dropdown-content">
- <a href="https://n2o.dev/deps/mad/man/ua/mad.htm">UA</a>
- <a href="https://mad.n2o.dev/man/mad.htm">EN</a>
- </div>
- </div>
- </nav><header>
- <a href="../index.html"><img src="https://openmoji.org/data/color/svg/26A1.svg" /></a>
- <h1>MAD</h1>
- </header><main>
- <section>
- <h3>INTRO</h3>
- <p>MAD module provides user level interface for console commands.</p>
- <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>
- </section>
- <section>
- <h3>PROFILE</h3>
- <p>Each MAD profile must imeplent exposed API:</p>
- <figure><code>
- -define(MAD,[compile/1,app/1,get/1,release/1,resolve/1,clean/1,
- start/1,attach/1,stop/1,sh/1,deps/1,up/1,fetch/1,
- static/1,eunit/1,strip/1]).
- </code></figure>
- <figure><code>
- -type return() :: [] | {ok,any()} | {error,any()}.
- </code></figure>
- <p>Each function from exposed API has same signature from list of string
- to sum of nil and error protocols.</p>
- <h4>compile(list(string())) -> return().</h4>
- <h4>app(list(string())) -> return().</h4>
- <h4>get(list(string())) -> return().</h4>
- <h4>release(list(string())) -> return().</h4>
- <h4>clean(list(string())) -> return().</h4>
- <h4>start(list(string())) -> return().</h4>
- <h4>stop(list(string())) -> return().</h4>
- <h4>sh(list(string())) -> return().</h4>
- <h4>deps(list(string())) -> return().</h4>
- <h4>up(list(string())) -> return().</h4>
- <h4>sh(list(string())) -> return().</h4>
- <h4>fetch(list(string())) -> return().</h4>
- <h4>static(list(string())) -> return().</h4>
- <h4>eunit(list(string())) -> return().</h4>
- <h4>strip(list(string())) -> return().</h4>
- </section>
- <section>
- <h3>LOOP</h3>
- <h4>main(list(string())) -> integer().</h4>
- <p>Simple yet understandable command processing and error loop.
- Function <b>atomize/1</b> helps to accumulate
- known arguments as atoms. Function <b>profile/0</b>
- retrieves module with MAD API implementation.
- <b>main/1</b> function returns error status to OS with halt.</p>
- <figure><code>
- main(Params) ->
- { _Invalid, Valid } = lists:foldr(
- fun (X,{C,R}) when is_atom(X) -> {[],[{X,C}|R]};
- (X,{C,R}) -> {[X|C],R}
- end, {[],[]}, lists:map(fun atomize/1, Params)),
- halt(return(
- lists:any(fun({error,X}) -> mad:info("~s~n",[X]), true;
- (_) -> false end,
- lists:flatten([
- lists:foldl(
- fun ({Fun,Arg},ErrAcc) ->
- mad_hooks:run_hooks(pre, Fun),
- Errors = errors((profile()):Fun(Arg)),
- mad_hooks:run_hooks(post, Fun),
- Errors ++ ErrAcc
- end, [], Valid)])))).
- </code></figure>
- </section>
- <section>
- <p>This module may refer to:
- <a href="mad_local.htm"><b>mad_local</b></a>.
- </p>
- </section>
- </main><footer>
- 2005—2018 © Synrc Research Center
- </footer>
- <script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
- </body></html>
|