This repository was archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkgassets.html
119 lines (116 loc) · 4.34 KB
/
pkgassets.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="../index.html">README</a>
</li>
<li>
<a href="../license.html">LICENSE</a>
</li>
<li>
<a href="../install.html">INSTALL</a>
</li>
<li>
<a href="./">Documentation</a>
</li>
<li>
<a href="https://github.com/caltechlibrary/cli">Github</a>
</li>
</ul>
</nav>
<section>
<h1 id="usage">
USAGE
</h1>
<pre><code>pkgassets [OPTIONS] VARIABLE_NAME DIR_HOLDING_ASSETS [VARIABLE_NAME DIR_HOLDING_ASSETS ...]</code></pre>
<h2 id="description">
DESCRIPTION
</h2>
<p>
<em>pkgassets</em> generates a Go source directory whos file assets are embedded in a <code>map[string][]byte</code> variable. This is useful where you want to embed web content, template source code, help docs and other assets that can be used for default behavior in a Go command line program or service.
</p>
<p>
The map content is harvested from directory holding the assets to be embedded. By default the path key starts with a slash and does not include the hosting directory (e.g. htdocs/index.html would become /index.html if htdocs was used to harvest assets). The prefix and suffix on the key can be modified based on <em>pkgassets</em>’s command line options.
</p>
<h2 id="options">
OPTIONS
</h2>
<p>
Below are a set of options available.
</p>
<pre><code> -X, -exclude A colon separted list of filenames to exclude, (e.g. 'nav.md:topics.md')
-c comment file to be included
-comment comment file to be included
-examples display example(s)
-ext Only include files with matching extension
-generate-manpage generate man page
-generate-markdown generate markdown documentation
-h, -help display help
-l, -license display license
-o, -output output filename
-p package name, if missing defauls to lowercase of variable name
-package package name, if missing defauls to lowercase of variable name
-quiet suppress error messages
-strip-prefix strip the prefix from the map key
-strip-suffix strip the suffix from the map key
-v, -version display version</code></pre>
<h2 id="examples">
EXAMPLES
</h2>
<p>
Usage examples.
</p>
<pre><code> pkgassets MAP_VARAIBLE_NAME NAME_OF_DIRECTORY_HOLDING_ASSETS</code></pre>
<p>
This will result in a Go of type map[string][]byte holding the assets discovered by walking the directory tree provided. The map’s key will represent a path (beginning with “/”) pointing at the asset ingested.
</p>
<pre class="shell"><code> pkgassets DefaultSite htdocs</code></pre>
<p>
Assuming that <em>htdocs</em> held
</p>
<ul>
<li>
index.html
</li>
<li>
css/site.css
</li>
</ul>
<p>
In this example the htdocs directory will be crawled and all the files found harvested as a an asset. The path in the map will not include htdocs and would result in a Go source file like
</p>
<pre class="golang"><code> package defaultsite
var DefaultSite = map[string][]byte{
"/index.html": []byte{}, // ... the contents of index.html would be here ...
"/css/site.css": []byte{}, // ... the contents of css/site.css would be here ...
}</code></pre>
<p>
If a package name is not provided then the package name will a lowercase name of the map variable name (e.g. “var DefaultSite” becomes “package defaultsite”). Likewise if a output name is not provided then the file name will be the name of the package plus the “.go” extension.
</p>
<p>
pkgassets v0.0.15
</p>
</section>
<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>© 2021 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:[email protected]">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>