This repository has been archived on 2022-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
arsenm-dev-site/public/docs/advmake/build-files/index.html

80 lines
31 KiB
HTML

<!doctype html><html lang=en-us><head><meta charset=utf-8><meta http-equiv=x-ua-compatible content="ie=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><script src=https://code.iconify.design/1/1.0.7/iconify.min.js></script><link rel=preload as=font href=/fonts/vendor/jost/jost-v4-latin-regular.woff2 type=font/woff2 crossorigin><link rel=preload as=font href=/fonts/vendor/jost/jost-v4-latin-700.woff2 type=font/woff2 crossorigin><link rel=stylesheet href=/main.db7090cddb6602125f0ed93682d138976ae6d5a9a2f2f92c4bcd4de73e6debc939331bf2ec54e8cd7b933fa961527404e59b7ddc6eede1ed4bb4cf90ad77caab.css integrity="sha512-23CQzdtmAhJfDtk2gtE4l2rm1ami8vksS81N5z5t68k5Mxvy7FTozXuTP6lhUnQE5Zt93G7t4e1LtM+QrXfKqw==" crossorigin=anonymous><noscript><style>img.lazyload{display:none}</style></noscript><meta name=robots content="index, follow"><meta name=googlebot content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><meta name=bingbot content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><title>Build Files | Arsen Dev</title><meta name=description content="Understanding AdvMake Build Files"><link rel=canonical href=/docs/advmake/build-files/><meta name=twitter:card content="summary"><meta name=twitter:title content="Build Files"><meta name=twitter:description content="Understanding AdvMake Build Files"><meta name=twitter:site content="@"><meta name=twitter:creator content="@"><meta property="og:title" content="Build Files"><meta property="og:description" content="Understanding AdvMake Build Files"><meta property="og:type" content="article"><meta property="og:url" content="/docs/advmake/build-files/"><meta property="og:site_name" content="Arsen Dev"><meta property="article:publisher" content="https://www.facebook.com/"><meta property="article:author" content="https://www.facebook.com/"><meta property="og:locale" content><script type=application/ld+json>{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"\/"},{"@type":"ListItem","position":2,"name":"Docsadvmakebuild Files","item":"\/docsadvmakebuild-files\/"}]}</script><meta name=theme-color content="#fff"><link rel=apple-touch-icon sizes=180x180 href=/apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=/favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=/favicon-16x16.png><link rel=manifest href=/site.webmanifest><link rel=stylesheet href=/css/highlightjs/dracula.min.css><script src=/js/highlightjs/highlight.min.js></script><script>hljs.initHighlightingOnLoad();</script></head><body class="docs single"><div class="header-bar fixed-top"></div><header class="navbar fixed-top navbar-expand-md navbar-light"><div class=container><input class="menu-btn order-0" type=checkbox id=menu-btn>
<label class="menu-icon d-md-none" for=menu-btn><span class=navicon></span></label><a class="navbar-brand order-1 order-md-0 mr-auto" href=/>Arsen Dev</a>
<button id=mode class="btn btn-link order-2 order-md-4" type=button aria-label="Toggle mode">
<span class=toggle-dark><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg></span><span class=toggle-light><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></span></button><ul class="navbar-nav social-nav order-3 order-md-5"><li class=nav-item><a class=nav-link href=https://gitea.arsenm.dev/Arsen6331><span class=iconify data-icon=cib:gitea data-inline=false></span><span class="ml-2 sr-only">Gitea</span></a></li><li class=nav-item><a class=nav-link href=https://gitlab.com/moussaelianarsen><span class=iconify data-icon=fa-brands:gitlab data-inline=false></span><span class="ml-2 sr-only">GitLab</span></a></li></ul><div class="collapse navbar-collapse order-4 order-md-1"><ul class="navbar-nav main-nav mr-auto order-5 order-md-2"><li class=nav-item><a class=nav-link href=/>Home</a></li><li class="nav-item active"><a class=nav-link href=/docs/>Docs</a></li></ul><div class="break order-6 d-md-none"></div><form class="navbar-form flex-grow-1 order-7 order-md-3"><input id=userinput class="form-control is-search" type=search placeholder="Search docs..." aria-label="Search docs..." autocomplete=off><div id=suggestions class="shadow bg-white rounded"></div></form></div></div></header><div class="wrap container" role=document><div class=content><div class="row flex-xl-nowrap"><div class="col-lg-5 col-xl-4 docs-sidebar"><nav class=docs-links aria-label="Main navigation"><h3>Docs</h3><ul class=list-unstyled><li><a class=docs-link href=/docs/advmake/>AdvMake Docs</a></li><li><a class=docs-link href=/docs/kbdemu/>KbdEmu Docs</a></li><li><a class=docs-link href=/docs/opensend/>OpenSend Docs</a></li><li><a class=docs-link href=/docs/pak/>Pak Docs</a></li><li><a class=docs-link href=/docs/simpledash/>Simpledash Docs</a></li></ul></nav></div><nav class="docs-toc d-none d-xl-block col-xl-3" aria-label="Secondary navigation"><div class=page-links><h3>On this page</h3><nav id=TableOfContents><ul><li><a href=#format>Format</a></li><li><a href=#configuration>Configuration</a></li><li><a href=#modules>Modules</a><ul><li><a href=#runtime><code>runtime</code></a></li><li><a href=#encoding><code>encoding</code></a></li><li><a href=#file><code>file</code></a></li><li><a href=#strings><code>strings</code></a></li><li><a href=#input><code>input</code></a></li><li><a href=#url><code>url</code></a></li><li><a href=#shell><code>shell</code></a></li><li><a href=#net><code>net</code></a></li><li><a href=#log><code>log</code></a></li><li><a href=#fmt><code>fmt</code></a></li></ul></li></ul></nav></div></nav><main class="docs-content col-lg-11 col-xl-9 mx-xl-auto"><a href=..>&lArr; AdvMake Docs</a><h1 style=margin-top:.2rem>Build Files</h1><p class=lead></p><p><a class=btn style=color:#fff;background-color:green href=https://gitea.arsenm.dev/Arsen6331/advmake><span class=iconify data-icon=cib:gitea></span>&nbsp;AdvMake</a>
<a class=btn style=color:#fff;background-color:OrangeRed href=https://www.gitlab.com/moussaelianarsen/advmake><span class=iconify data-icon=fa-brands:gitlab></span>&nbsp;AdvMake</a></p><h2 id=format>Format<a href=#format class=anchor aria-hidden=true>#</a></h2><p>AdvMake uses <a href=https://github.com/bazelbuild/starlark>Starlark</a> as the format for its build files.
Modules are also defined for both convenience and extra functionality.</p><p>Starlark is a Python-like language meant for configuration files.</p><h2 id=configuration>Configuration<a href=#configuration class=anchor aria-hidden=true>#</a></h2><p>Build files are by default called <code>AdvMakefile</code>, but that can be set via <code>-f</code></p><p>An AdvMakefile example can be found at AdvMake&rsquo;s repo as it uses AdvMake itself.</p><p>AdvMake runs functions exposed by starlark in the format <code>&lt;name>_&lt;target></code>.
To set the default name and target, the global variables <code>defaultName</code>, and <code>defaultTarget</code> must be set.
Here is an example from AdvMake&rsquo;s AdvMakefile:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>defaultName</span> <span class=o>=</span> <span class=s2>&#34;advmake&#34;</span>
<span class=n>defaultTarget</span> <span class=o>=</span> <span class=s2>&#34;build&#34;</span>
</code></pre></div><p>This will tell AdvMake to run the function <code>advmake_build()</code> when run with no arguments.</p><p>If AdvMake is run with one argument (such as <code>advmake install</code>), it will use the default name with the specified target,
so in that case, it would run <code>advmake_install()</code>.</p><p>If run with two arguments, AdvMake will use the first argument as the name and the second as the target.
So, running <code>advmake hello world</code> would run the function <code>hello_world()</code>.</p><h2 id=modules>Modules<a href=#modules class=anchor aria-hidden=true>#</a></h2><p>As previously mentioned, AdvMake comes with modules. Those are as follows:</p><h3 id=runtime><code>runtime</code><a href=#runtime class=anchor aria-hidden=true>#</a></h3><p>The runtime module exposes some of golang&rsquo;s runtime methods and variables.</p><hr><h4 id=runtimegoos><code>runtime.GOOS</code><a href=#runtimegoos class=anchor aria-hidden=true>#</a></h4><p>Stores a string denoting the operating system being used.</p><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/runtime#GOOS><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h4 id=runtimegoarch><code>runtime.GOARCH</code><a href=#runtimegoarch class=anchor aria-hidden=true>#</a></h4><p>Stores a string denoting the CPU architecture being used.</p><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/runtime#GOARCH><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h4 id=runtimenumcpu><code>runtime.NumCPU()</code><a href=#runtimenumcpu class=anchor aria-hidden=true>#</a></h4><p>Get the number of logical CPUs available to the current process</p><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/runtime#NumCPU><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h4 id=runtimegomaxprocs><code>runtime.GOMAXPROCS()</code><a href=#runtimegomaxprocs class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>runtime.GOMAXPROCS(n)</code></p><p>Get or set the value of the GOMAXPROCS environment variable. This variable controls the maximum number of CPUs that can execute. This function will set GOMAXPROCS to n and then return the previous value. If <code>n&lt;1</code>, this function will not set the variable and will instead return the current setting</p><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/runtime#GOMAXPROCS><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h3 id=encoding><code>encoding</code><a href=#encoding class=anchor aria-hidden=true>#</a></h3><p>The strings module contains functions for encoding and decoding various formats. This module contains submodules for the various formats</p><p>Available submodules:</p><ul><li><code>Json</code></li><li><code>Yaml</code></li><li><code>Toml</code></li><li><code>Hex</code></li></ul><hr><h4 id=encodingsubmoduleload><code>encoding.&lt;Submodule>.Load()</code><a href=#encodingsubmoduleload class=anchor aria-hidden=true>#</a></h4><p>Load a string formatted as the submodule format into a dictionary or string.</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>x</span> <span class=o>=</span> <span class=n>encoding</span><span class=o>.</span><span class=n>Json</span><span class=o>.</span><span class=n>Load</span><span class=p>(</span><span class=s1>&#39;{&#34;encoding&#34;: &#34;json&#34;}&#39;</span><span class=p>)</span>
<span class=c1># x[&#34;encoding&#34;] == &#34;json&#34;</span>
<span class=n>y</span> <span class=o>=</span> <span class=n>encoding</span><span class=o>.</span><span class=n>Hex</span><span class=o>.</span><span class=n>Load</span><span class=p>(</span><span class=s1>&#39;546573740a&#39;</span><span class=p>)</span>
<span class=c1># y == &#34;Test&#34;</span>
</code></pre></div><hr><h4 id=encodingsubmoduledump><code>encoding.&lt;Submodule>.Dump()</code><a href=#encodingsubmoduledump class=anchor aria-hidden=true>#</a></h4><p>Dump a string formatted as the submodule format from a dictionary or string</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>xDict</span> <span class=o>=</span> <span class=p>{</span><span class=s2>&#34;encoding&#34;</span><span class=p>:</span> <span class=p>{</span><span class=s2>&#34;type&#34;</span><span class=p>:</span> <span class=s2>&#34;toml&#34;</span><span class=p>}}</span>
<span class=n>x</span> <span class=o>=</span> <span class=n>encoding</span><span class=o>.</span><span class=n>Toml</span><span class=o>.</span><span class=n>Dump</span><span class=p>(</span><span class=n>xDict</span><span class=p>)</span>
<span class=c1># x == &#39;&#39;&#39;</span>
<span class=c1>#</span>
<span class=c1># [encoding]</span>
<span class=c1># type = &#34;toml&#34;</span>
<span class=c1>#</span>
<span class=c1># &#39;&#39;&#39;</span>
<span class=n>y</span> <span class=o>=</span> <span class=n>encoding</span><span class=o>.</span><span class=n>Hex</span><span class=o>.</span><span class=n>Dump</span><span class=p>(</span><span class=s2>&#34;Test&#34;</span><span class=p>)</span>
<span class=c1># y = &#34;546573740a&#34;</span>
</code></pre></div><hr><h3 id=file><code>file</code><a href=#file class=anchor aria-hidden=true>#</a></h3><p>The file module contains functions for manipulation and checking of files</p><hr><h4 id=fileexpand><code>file.Expand()</code><a href=#fileexpand class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>file.Expand(file, mappings)</code></p><p>Expand any instances of <code>$VAR</code> in a file according to provided mappings.</p><p>Examples:</p><p><code>file.txt</code> before:</p><div class=highlight><pre class=chroma><code class=language-text data-lang=text>I am running on $OS and architecture $arch
</code></pre></div><p>Code:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=nb>file</span><span class=o>.</span><span class=n>Expand</span><span class=p>(</span><span class=s2>&#34;file.txt&#34;</span><span class=p>,</span> <span class=p>{</span><span class=s2>&#34;OS&#34;</span><span class=p>:</span> <span class=n>runtime</span><span class=o>.</span><span class=n>GOOS</span><span class=p>,</span> <span class=s2>&#34;arch&#34;</span><span class=p>:</span> <span class=n>runtime</span><span class=o>.</span><span class=n>GOARCH</span><span class=p>})</span>
</code></pre></div><p><code>file.txt</code> after:</p><div class=highlight><pre class=chroma><code class=language-text data-lang=text>I am running on linux and architecture x86_64
</code></pre></div><hr><h4 id=fileexists><code>file.Exists()</code><a href=#fileexists class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>file.Exists(filepath)</code></p><p>Check whether a file exists</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=nb>file</span><span class=o>.</span><span class=n>Exists</span><span class=p>(</span><span class=s2>&#34;/etc/fstab&#34;</span><span class=p>)</span> <span class=c1># True</span>
</code></pre></div><hr><h4 id=filecontent><code>file.Content()</code><a href=#filecontent class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>file.Content(filepath)</code></p><p>Returns contents of a file as a string</p><p>Example:</p><p>file.txt:</p><div class=highlight><pre class=chroma><code class=language-text data-lang=text>This is a file
</code></pre></div><p>Code:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=nb>file</span><span class=o>.</span><span class=n>Content</span><span class=p>(</span><span class=s2>&#34;file.txt&#34;</span><span class=p>)</span> <span class=c1># &#34;This is a file&#34;</span>
</code></pre></div><hr><h3 id=strings><code>strings</code><a href=#strings class=anchor aria-hidden=true>#</a></h3><p>The strings module contains functions for the manipulation of strings</p><hr><h4 id=stringsregex><code>strings.Regex()</code><a href=#stringsregex class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>strings.Regex(string, pattern, regex)</code></p><p>Parse a string using a regular expression and return the result in the specified format.</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>x</span> <span class=o>=</span> <span class=n>strings</span><span class=o>.</span><span class=n>Regex</span><span class=p>(</span><span class=s2>&#34;Hello, World&#34;</span><span class=p>,</span> <span class=s2>&#34;$2, $1&#34;</span><span class=p>,</span> <span class=s2>&#34;(.+), (.+)&#34;</span><span class=p>)</span>
<span class=c1># x == &#34;World, Hello&#34;</span>
<span class=n>y</span> <span class=o>=</span> <span class=n>strings</span><span class=o>.</span><span class=n>Regex</span><span class=p>(</span><span class=s2>&#34;Hello, World&#34;</span><span class=p>,</span> <span class=s2>&#34;$y, $x&#34;</span><span class=p>,</span> <span class=s2>&#34;(?P&lt;x&gt;.+), (?P&lt;y&gt;.+)&#34;</span><span class=p>)</span>
<span class=c1># y == &#34;World, Hello&#34;</span>
<span class=n>z</span> <span class=o>=</span> <span class=n>strings</span><span class=o>.</span><span class=n>Regex</span><span class=p>(</span><span class=s2>&#34;Hello, World&#34;</span><span class=p>,</span> <span class=s2>&#34;$match, $2, $1&#34;</span><span class=p>,</span> <span class=s2>&#34;(.+), (.+)&#34;</span><span class=p>)</span>
<span class=c1># z == &#34;Hello, World, World, Hello&#34;</span>
</code></pre></div><hr><h4 id=stringshassuffix><code>strings.HasSuffix()</code><a href=#stringshassuffix class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>strings.HasSuffix(string, suffix)</code></p><p>Check whether a string ends with a suffix.</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>strings</span><span class=o>.</span><span class=n>HasSuffix</span><span class=p>(</span><span class=s2>&#34;doc.pdf&#34;</span><span class=p>,</span> <span class=s2>&#34;.pdf&#34;</span><span class=p>)</span> <span class=c1># True</span>
<span class=n>strings</span><span class=o>.</span><span class=n>HasSuffix</span><span class=p>(</span><span class=s2>&#34;doc.pdf&#34;</span><span class=p>,</span> <span class=s2>&#34;.md&#34;</span><span class=p>)</span> <span class=c1># False</span>
</code></pre></div><hr><h4 id=stringshasprefix><code>strings.HasPrefix()</code><a href=#stringshasprefix class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>strings.HasPrefix(string, prefix)</code></p><p>Check whether a string starts with a prefix.</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>strings</span><span class=o>.</span><span class=n>HasPrefix</span><span class=p>(</span><span class=s2>&#34;doc.pdf&#34;</span><span class=p>,</span> <span class=s2>&#34;doc&#34;</span><span class=p>)</span> <span class=c1># True</span>
</code></pre></div><hr><h4 id=stringstrimsuffix><code>strings.TrimSuffix()</code><a href=#stringstrimsuffix class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>strings.HasSuffix(string, suffix)</code></p><p>Remove suffix from string if it exists. If it does not exist, the string is returned unchanged.</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>strings</span><span class=o>.</span><span class=n>TrimSuffix</span><span class=p>(</span><span class=s2>&#34;doc.pdf&#34;</span><span class=p>,</span> <span class=s2>&#34;.pdf&#34;</span><span class=p>)</span> <span class=c1># &#34;doc&#34;</span>
</code></pre></div><hr><h4 id=stringstrimprefix><code>strings.TrimPrefix()</code><a href=#stringstrimprefix class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>strings.TrimPrefix(string, prefix)</code></p><p>Remove prefix from string if it exists. If it does not exist, the string is returned unchanged.</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>strings</span><span class=o>.</span><span class=n>TrimPrefix</span><span class=p>(</span><span class=s2>&#34;doc.pdf&#34;</span><span class=p>,</span> <span class=s2>&#34;doc&#34;</span><span class=p>)</span> <span class=c1># &#34;.pdf&#34;</span>
</code></pre></div><hr><h4 id=stringstrimspace><code>strings.TrimSpace()</code><a href=#stringstrimspace class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>strings.TrimSpace(string)</code></p><p>Trim leading and trailing white space, as defined by Unicode</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>strings</span><span class=o>.</span><span class=n>TrimSpace</span><span class=p>(</span><span class=s2>&#34; Hi &#34;</span><span class=p>)</span> <span class=c1># &#34;Hi&#34;</span>
</code></pre></div><hr><h3 id=input><code>input</code><a href=#input class=anchor aria-hidden=true>#</a></h3><p>The input module prompts the user for input</p><hr><h4 id=inputprompt><code>input.Prompt()</code><a href=#inputprompt class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>input.Prompt(prompt)</code></p><p>Print prompt and wait for input, returning on newline</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=nb>input</span><span class=o>.</span><span class=n>Prompt</span><span class=p>(</span><span class=s2>&#34;Enter number: &#34;</span><span class=p>)</span>
</code></pre></div><hr><h4 id=inputchoice><code>input.Choice()</code><a href=#inputchoice class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>input.Choice(prompt, choices)</code></p><p>Assign number to each choice and prompt user to choose one</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=nb>input</span><span class=o>.</span><span class=n>Choice</span><span class=p>(</span><span class=s2>&#34;Choose greeting&#34;</span><span class=p>,</span> <span class=p>[</span><span class=s2>&#34;Hi&#34;</span><span class=p>,</span> <span class=s2>&#34;Hello&#34;</span><span class=p>,</span> <span class=s2>&#34;Good morning&#34;</span><span class=p>])</span>
</code></pre></div><p>The above example looks like this to the user:</p><div class=highlight><pre class=chroma><code class=language-text data-lang=text>[1] &#34;Hi&#34;
[2] &#34;Hello&#34;
[3] &#34;Good Morning&#34;
Choose greeting:
</code></pre></div><p>When the user chooses a number, the function will return the associated string. So, if the user chooses 1, <code>"Hi"</code> will be returned.</p><hr><h3 id=url><code>url</code><a href=#url class=anchor aria-hidden=true>#</a></h3><p>The url module contains functions for the manipulation of URLs</p><hr><h4 id=urlparse><code>url.Parse()</code><a href=#urlparse class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>url.Parse(urlString)</code></p><p>Parses a URL and returns its components</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>parsed</span> <span class=o>=</span> <span class=n>url</span><span class=o>.</span><span class=n>Parse</span><span class=p>(</span><span class=s2>&#34;https://www.arsenm.dev/docs/advmake/build-files&#34;</span><span class=p>)</span>
<span class=c1># parsed.Scheme == &#34;https&#34;</span>
<span class=c1># parsed.Host == &#34;www.arsenm.dev&#34;</span>
<span class=c1># parsed.Path == &#34;/docs/advmake/build-files&#34;</span>
</code></pre></div><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/net/url#URL><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h3 id=shell><code>shell</code><a href=#shell class=anchor aria-hidden=true>#</a></h3><p>The shell module contains functions for accessing and utilizing the shell.</p><hr><h4 id=shellexec><code>shell.Exec()</code><a href=#shellexec class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>shell.Exec(command, output?, concurrent?)</code></p><p>Runs a command or script using <code>sh -c</code>, sending the output to <code>STDOUT</code> and returning it unless set otherwise. It can also be concurrent.</p><p>Examples:</p><p>Code:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>x</span> <span class=o>=</span> <span class=n>shell</span><span class=o>.</span><span class=n>Exec</span><span class=p>(</span><span class=s2>&#34;date +</span><span class=si>%r</span><span class=s2>&#34;</span><span class=p>)</span> <span class=c1># &#34;12:00:00 AM&#34;</span>
<span class=n>y</span> <span class=o>=</span> <span class=n>shell</span><span class=o>.</span><span class=n>Exec</span><span class=p>(</span><span class=s2>&#34;date +</span><span class=si>%r</span><span class=s2>&#34;</span><span class=p>,</span> <span class=n>output</span><span class=o>=</span><span class=s1>&#39;return&#39;</span><span class=p>)</span> <span class=c1># &#34;12:00:00 AM&#34;</span>
<span class=n>z</span> <span class=o>=</span> <span class=n>shell</span><span class=o>.</span><span class=n>Exec</span><span class=p>(</span><span class=s2>&#34;date +</span><span class=si>%r</span><span class=s2> | base64&#34;</span><span class=p>,</span> <span class=n>output</span><span class=o>=</span><span class=s1>&#39;stdout&#39;</span><span class=p>)</span> <span class=c1># None</span>
<span class=n>shell</span><span class=o>.</span><span class=n>Exec</span><span class=p>(</span><span class=s2>&#34;&#34;&#34;
</span><span class=s2> sleep 1
</span><span class=s2> sleep 2
</span><span class=s2>&#34;&#34;&#34;</span><span class=p>,</span> <span class=n>concurrent</span><span class=o>=</span><span class=bp>True</span><span class=p>)</span> <span class=c1># Sleeps for two seconds</span>
</code></pre></div><p>STDOUT:</p><div class=highlight><pre class=chroma><code class=language-text data-lang=text>12:00:00 AM
MTI6MDA6MDAgQU0K
</code></pre></div><hr><h4 id=shellgetenv><code>shell.Getenv()</code><a href=#shellgetenv class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>shell.Getenv(key)</code></p><p>Returns the value of an environment variable</p><p>Example:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>shell</span><span class=o>.</span><span class=n>Getenv</span><span class=p>(</span><span class=s1>&#39;TERM&#39;</span><span class=p>)</span> <span class=c1># &#34;xterm&#34;</span>
</code></pre></div><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/os#Getenv><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h4 id=shellsetenv><code>shell.Setenv()</code><a href=#shellsetenv class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>shell.Setenv(key, value, onlyIfUnset?)</code></p><p>Sets the value of an environment variable. It can be configured not to set the value if it is already set</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>shell</span><span class=o>.</span><span class=n>Setenv</span><span class=p>(</span><span class=s2>&#34;X&#34;</span><span class=p>,</span> <span class=s2>&#34;x&#34;</span><span class=p>)</span> <span class=c1># $X = x</span>
<span class=n>shell</span><span class=o>.</span><span class=n>Setenv</span><span class=p>(</span><span class=s2>&#34;CC&#34;</span><span class=p>,</span> <span class=s2>&#34;gcc&#34;</span><span class=p>)</span> <span class=c1># if $CC unset, $CC = gcc</span>
</code></pre></div><hr><h4 id=shelllookpath><code>shell.LookPath()</code><a href=#shelllookpath class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>shell.LookPath(command)</code></p><p>Returns the path to the executable of the specified command. Returns <code>-1</code> if the command is not found in <code>PATH</code>.</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>shell</span><span class=o>.</span><span class=n>LookPath</span><span class=p>(</span><span class=s1>&#39;sh&#39;</span><span class=p>)</span> <span class=c1># &#34;/bin/sh&#34;</span>
<span class=n>shell</span><span class=o>.</span><span class=n>LookPath</span><span class=p>(</span><span class=s1>&#39;nonExistentCommand&#39;</span><span class=p>)</span> <span class=c1># -1</span>
</code></pre></div><hr><h3 id=net><code>net</code><a href=#net class=anchor aria-hidden=true>#</a></h3><p>The net module contains various network functions</p><hr><h4 id=netdownload><code>net.Download()</code><a href=#netdownload class=anchor aria-hidden=true>#</a></h4><p>Download a file from a URL, optionally specifying the filename. It will show progress if the <code>Content-Length</code> header is present.</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>net</span><span class=o>.</span><span class=n>Download</span><span class=p>(</span><span class=s2>&#34;https://minio.arsenm.dev/advmake/0.0.1/advmake-linux-x86_64&#34;</span><span class=p>)</span>
<span class=n>net</span><span class=o>.</span><span class=n>Download</span><span class=p>(</span><span class=s2>&#34;https://minio.arsenm.dev/advmake/0.0.1/advmake-linux-x86_64&#34;</span><span class=p>,</span> <span class=n>filename</span><span class=o>=</span><span class=s2>&#34;advmake&#34;</span><span class=p>)</span>
</code></pre></div><hr><h3 id=log><code>log</code><a href=#log class=anchor aria-hidden=true>#</a></h3><p>The log module contains functions to log events at various levels</p><p>The available levels are:</p><ul><li><code>Info</code></li><li><code>Debug</code></li><li><code>Warn</code></li><li><code>Fatal</code></li></ul><hr><h4 id=loglevel><code>log.&lt;Level>()</code><a href=#loglevel class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>log.&lt;Level>(message)</code></p><p>Logs a message at the specified level. The fatal level quits after logging the message.</p><p>Examples:</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>log</span><span class=o>.</span><span class=n>Info</span><span class=p>(</span><span class=s2>&#34;Test log&#34;</span><span class=p>)</span>
<span class=n>log</span><span class=o>.</span><span class=n>Fatal</span><span class=p>(</span><span class=s2>&#34;Error&#34;</span><span class=p>)</span>
</code></pre></div><hr><h3 id=fmt><code>fmt</code><a href=#fmt class=anchor aria-hidden=true>#</a></h3><p>The fmt module exposes all the text functions from the golang fmt package except for all the <code>Fprint</code> and <code>Fscan</code> functions.</p><div class=highlight><pre class=chroma><code class=language-python data-lang=python><span class=n>fmt</span><span class=o>.</span><span class=n>Sprintf</span><span class=p>(</span><span class=s2>&#34;Print </span><span class=si>%s</span><span class=s2> string&#34;</span><span class=p>,</span> <span class=s2>&#34;formatted&#34;</span><span class=p>)</span> <span class=c1># &#34;Print formatted string&#34;</span>
</code></pre></div><a class=btn style=color:#fff;background-color:#00acd7 href=https://pkg.go.dev/fmt><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a></main></div></div></div><script src=/main.f6b484f556ad1f3bcf6061082139a2f21fa759f13930c39a25fe4a9f78f35e64122c2d86dffd56e67b292dabbda4095d8077194f196e0e348441c106a9f3d40e.js integrity="sha512-9rSE9VatHzvPYGEIITmi8h+nWfE5MMOaJf5Kn3jzXmQSLC2G3/1W5nspLau9pAldgHcZTxluDjSEQcEGqfPUDg==" crossorigin=anonymous defer></script><script src=/index.min.519647b94aaacaa6fa73ffc9e4bda4ccc0d6ab69b03000caea7466a9dc6806cf38f9d8c6926c09e49970a5fe43183e0d589a028bbf3b8ef0ef5c98fc6fb78206.js integrity="sha512-UZZHuUqqyqb6c//J5L2kzMDWq2mwMADK6nRmqdxoBs84+djGkmwJ5Jlwpf5DGD4NWJoCi787jvDvXJj8b7eCBg==" crossorigin=anonymous defer></script></body></html>