-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration improvements - Environment variable support, docs, CLI …
…flag tweaks (#138) * Support setting config options via environment variables Fix path handling for windows in config tests Add JSON tags and make field naming more consistent Generate CLI flags from struct Flat map is generated on the fly (fewer allocations) Renames and minor tweaks Add CLI flag descriptions Rename file Minor restructuring Minor tweaks First draft of a documentation generation tool Adding templ code and some styling info Style tweaks Add option to disable file embedding Promote documentation code Add a warning for using tabs in struct tags * Making config package not-internal
- Loading branch information
Showing
24 changed files
with
1,339 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #dce4e8; | ||
color: #333; | ||
margin: 20px; | ||
padding: 20px; | ||
} | ||
|
||
h1 { | ||
color: #333; | ||
border-bottom: 1px solid #ccc; | ||
padding-bottom: 10px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
h3 { | ||
color: #666; | ||
margin-top: 20px; | ||
} | ||
|
||
ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
li { | ||
margin-bottom: 20px; | ||
padding: 20px; | ||
} | ||
|
||
li.cfg { | ||
background-color: #fff; | ||
border-radius: 15px; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
margin-bottom: 20px; | ||
padding: 20px; | ||
} | ||
|
||
li.child-cfg { | ||
background-color: #fefefe; | ||
border-radius: 15px; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
margin-bottom: 20px; | ||
padding: 20px; | ||
} | ||
|
||
li.cli { | ||
background-color: #edf2f5; | ||
margin-bottom: 10px; | ||
margin-right: 30px; | ||
margin-left: 30px; | ||
padding: 10px; | ||
} | ||
|
||
.cli-details { | ||
margin-left: 20px; | ||
} | ||
|
||
h3 { | ||
color: #333; | ||
margin-top: 0; | ||
} | ||
|
||
p { | ||
margin: 5px 0; | ||
} | ||
|
||
dl { | ||
margin: 0; | ||
} | ||
|
||
dt { | ||
margin-bottom: 15px; | ||
} | ||
|
||
dd { | ||
margin-left: 0; | ||
} | ||
|
||
code { | ||
background-color: #f5f5f5; | ||
padding: 2px 5px; | ||
border-radius: 3px; | ||
} | ||
|
||
.link-icon { | ||
margin-left: 5px; | ||
font-size: 80%; | ||
color: #888; | ||
text-decoration: none; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package main | ||
|
||
import "fmt" | ||
import "github.com/blocklessnetwork/b7s/config" | ||
|
||
templ page(configs []config.ConfigOption) { | ||
<html> | ||
<head> | ||
<title>Blockless B7S Node Configuration</title> | ||
<link rel="icon" href="/assets/favicon/favicon.ico" type="image/x-icon" sizes="16x16"/> | ||
<link rel="stylesheet" href="/assets/css/style.css" /> | ||
</head> | ||
<body> | ||
<h1>Blockless B7S Node Configuration</h1> | ||
<p> | ||
This page lists all of the configuration options supported by the b7s daemon. | ||
It showcases the configuration structure, as accepted in a YAML config file, environment variables that can be used to set those options and, where applicable, the CLI flags and their default values. | ||
</p> | ||
|
||
@b7sdocs(configs) | ||
</body> | ||
</html> | ||
} | ||
|
||
|
||
templ b7sdocs(configs []config.ConfigOption) { | ||
|
||
<ul> | ||
for _, cfg := range configs { | ||
<li class="cfg"> | ||
@configOption(cfg) | ||
</li> | ||
} | ||
</ul> | ||
} | ||
|
||
func formatCLIDefault(def any) string { | ||
str := fmt.Sprint(def) | ||
if str != "" { | ||
return str | ||
} | ||
|
||
return "N/A" | ||
} | ||
|
||
templ configOption(cfg config.ConfigOption) { | ||
|
||
<h3 id={cfg.FullPath}>{cfg.Name} <a class="link-icon" href={ templ.URL(fmt.Sprintf("#%s", cfg.FullPath)) }><span >🔗</span></a></h3> | ||
|
||
if cfg.Type() != "" { | ||
<p>Type: {cfg.Type()}</p> | ||
} | ||
|
||
<p>Path: {cfg.FullPath}</p> | ||
if cfg.Env != "" { | ||
<p>Environment variable: {cfg.Env}</p> | ||
} | ||
|
||
if cfg.CLI.Flag != "" { | ||
|
||
<dl> | ||
<dt>CLI flag:</dt> | ||
<dd> | ||
<ul class="cli-details"> | ||
<li class="cli">Flag: <code>--{cfg.CLI.Flag}</code></li> | ||
if cfg.CLI.Shorthand != "" { | ||
<li class="cli">Shorthand: <code>-{cfg.CLI.Shorthand}</code></li> | ||
} | ||
|
||
<li class="cli">Default: {formatCLIDefault(cfg.CLI.Default)}</li> | ||
<li class="cli">Description: {cfg.CLI.Description}</li> | ||
</ul> | ||
</dd> | ||
</dl> | ||
} | ||
|
||
if len(cfg.Children) > 0 { | ||
<ul> | ||
for _, child := range cfg.Children { | ||
<li class="child-cfg"> | ||
@configOption(child) | ||
</li> | ||
} | ||
</ul> | ||
} | ||
} |
Oops, something went wrong.