79 lines
31 KiB
HTML
79 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.b5b102cb07e11c96e0608794497ef63d0b871bb82bc08c3013ceeabf602ed21bf546785133e3aa9718609cf943bd299e4bc350707f19ffc6c0d620a7a5d9a023.css integrity="sha512-tbECywfhHJbgYIeUSX72PQuHG7grwIwwE87qv2Au0hv1RnhRM+OqlxhgnPlDvSmeS8NQcH8Z/8bA1iCnpdmgIw==" 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/opensend/>OpenSend Docs</a></li><li><a class=docs-link href=/docs/pak/>Pak 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=..>⇐ 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> 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> 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’s repo as it uses AdvMake itself.</p><p>AdvMake runs functions exposed by starlark in the format <code><name>_<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’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>"advmake"</span>
|
|
<span class=n>defaultTarget</span> <span class=o>=</span> <span class=s2>"build"</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’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>
|
|
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>
|
|
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>
|
|
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<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>
|
|
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.<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>'{"encoding": "json"}'</span><span class=p>)</span>
|
|
<span class=c1># x["encoding"] == "json"</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>'546573740a'</span><span class=p>)</span>
|
|
<span class=c1># y == "Test"</span>
|
|
</code></pre></div><hr><h4 id=encodingsubmoduledump><code>encoding.<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>"encoding"</span><span class=p>:</span> <span class=p>{</span><span class=s2>"type"</span><span class=p>:</span> <span class=s2>"toml"</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 == '''</span>
|
|
<span class=c1>#</span>
|
|
<span class=c1># [encoding]</span>
|
|
<span class=c1># type = "toml"</span>
|
|
<span class=c1>#</span>
|
|
<span class=c1># '''</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>"Test"</span><span class=p>)</span>
|
|
<span class=c1># y = "546573740a"</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>"file.txt"</span><span class=p>,</span> <span class=p>{</span><span class=s2>"OS"</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>"arch"</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>"/etc/fstab"</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>"file.txt"</span><span class=p>)</span> <span class=c1># "This is a file"</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>"Hello, World"</span><span class=p>,</span> <span class=s2>"$2, $1"</span><span class=p>,</span> <span class=s2>"(.+), (.+)"</span><span class=p>)</span>
|
|
<span class=c1># x == "World, Hello"</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>"Hello, World"</span><span class=p>,</span> <span class=s2>"$y, $x"</span><span class=p>,</span> <span class=s2>"(?P<x>.+), (?P<y>.+)"</span><span class=p>)</span>
|
|
<span class=c1># y == "World, Hello"</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>"Hello, World"</span><span class=p>,</span> <span class=s2>"$match, $2, $1"</span><span class=p>,</span> <span class=s2>"(.+), (.+)"</span><span class=p>)</span>
|
|
<span class=c1># z == "Hello, World, World, Hello"</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>"doc.pdf"</span><span class=p>,</span> <span class=s2>".pdf"</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>"doc.pdf"</span><span class=p>,</span> <span class=s2>".md"</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>"doc.pdf"</span><span class=p>,</span> <span class=s2>"doc"</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>"doc.pdf"</span><span class=p>,</span> <span class=s2>".pdf"</span><span class=p>)</span> <span class=c1># "doc"</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>"doc.pdf"</span><span class=p>,</span> <span class=s2>"doc"</span><span class=p>)</span> <span class=c1># ".pdf"</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>" Hi "</span><span class=p>)</span> <span class=c1># "Hi"</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>"Enter number: "</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>"Choose greeting"</span><span class=p>,</span> <span class=p>[</span><span class=s2>"Hi"</span><span class=p>,</span> <span class=s2>"Hello"</span><span class=p>,</span> <span class=s2>"Good morning"</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] "Hi"
|
|
[2] "Hello"
|
|
[3] "Good Morning"
|
|
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>"https://www.arsenm.dev/docs/advmake/build-files"</span><span class=p>)</span>
|
|
<span class=c1># parsed.Scheme == "https"</span>
|
|
<span class=c1># parsed.Host == "www.arsenm.dev"</span>
|
|
<span class=c1># parsed.Path == "/docs/advmake/build-files"</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>
|
|
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>"date +</span><span class=si>%r</span><span class=s2>"</span><span class=p>)</span> <span class=c1># "12:00:00 AM"</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>"date +</span><span class=si>%r</span><span class=s2>"</span><span class=p>,</span> <span class=n>output</span><span class=o>=</span><span class=s1>'return'</span><span class=p>)</span> <span class=c1># "12:00:00 AM"</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>"date +</span><span class=si>%r</span><span class=s2> | base64"</span><span class=p>,</span> <span class=n>output</span><span class=o>=</span><span class=s1>'stdout'</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>"""
|
|
</span><span class=s2> sleep 1
|
|
</span><span class=s2> sleep 2
|
|
</span><span class=s2>"""</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>'TERM'</span><span class=p>)</span> <span class=c1># "xterm"</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>
|
|
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>"X"</span><span class=p>,</span> <span class=s2>"x"</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>"CC"</span><span class=p>,</span> <span class=s2>"gcc"</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>'sh'</span><span class=p>)</span> <span class=c1># "/bin/sh"</span>
|
|
<span class=n>shell</span><span class=o>.</span><span class=n>LookPath</span><span class=p>(</span><span class=s1>'nonExistentCommand'</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>"https://minio.arsenm.dev/advmake/0.0.1/advmake-linux-x86_64"</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>"https://minio.arsenm.dev/advmake/0.0.1/advmake-linux-x86_64"</span><span class=p>,</span> <span class=n>filename</span><span class=o>=</span><span class=s2>"advmake"</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.<Level>()</code><a href=#loglevel class=anchor aria-hidden=true>#</a></h4><p>Definition: <code>log.<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>"Test log"</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>"Error"</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>"Print </span><span class=si>%s</span><span class=s2> string"</span><span class=p>,</span> <span class=s2>"formatted"</span><span class=p>)</span> <span class=c1># "Print formatted string"</span>
|
|
</code></pre></div></main></div></div></div><script src=/main.f6b484f556ad1f3bcf6061082139a2f21fa759f13930c39a25fe4a9f78f35e64122c2d86dffd56e67b292dabbda4095d8077194f196e0e348441c106a9f3d40e.js integrity="sha512-9rSE9VatHzvPYGEIITmi8h+nWfE5MMOaJf5Kn3jzXmQSLC2G3/1W5nspLau9pAldgHcZTxluDjSEQcEGqfPUDg==" crossorigin=anonymous defer></script><script src=/index.min.8c5e6bee4f123cf4e419f9c92fb0ae638d0378a1c527c8d9da60244ac6676ae1a889ddeb67ff6329a913a6134e4967e011c84af5191b23f15c0bf22f0c452739.js integrity="sha512-jF5r7k8SPPTkGfnJL7CuY40DeKHFJ8jZ2mAkSsZnauGoid3rZ/9jKakTphNOSWfgEchK9RkbI/FcC/IvDEUnOQ==" crossorigin=anonymous defer></script></body></html> |