mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-05 17:40:26 +00:00
Add -print-example-config
This commit is contained in:
parent
d2792ff83d
commit
e35643bb9d
6
Makefile
6
Makefile
@ -1,12 +1,6 @@
|
||||
run: build
|
||||
./mycorrhiza metarrhiza
|
||||
|
||||
auth_run: build
|
||||
./mycorrhiza -auth-method fixed metarrhiza
|
||||
|
||||
gemini_run: build
|
||||
./mycorrhiza -gemini-cert-path "." metarrhiza
|
||||
|
||||
config_run: build
|
||||
./mycorrhiza -config-path "assets/config.ini" metarrhiza
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
{%- func HelpMessage() -%}
|
||||
Usage of %s:
|
||||
{%- endfunc -%}
|
||||
|
||||
{%- func ExampleConfig() -%}
|
||||
{% cat "config.ini" %}
|
||||
{%- endfunc -%}
|
||||
|
||||
{% func DefaultCSS() %}
|
||||
{% cat "default.css" %}
|
||||
{% endfunc %}
|
||||
|
@ -18,11 +18,97 @@ var (
|
||||
)
|
||||
|
||||
//line assets/assets.qtpl:1
|
||||
func StreamDefaultCSS(qw422016 *qt422016.Writer) {
|
||||
func StreamHelpMessage(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:1
|
||||
qw422016.N().S(`Usage of %s:
|
||||
`)
|
||||
//line assets/assets.qtpl:3
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:3
|
||||
func WriteHelpMessage(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:3
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:3
|
||||
StreamHelpMessage(qw422016)
|
||||
//line assets/assets.qtpl:3
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:3
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:3
|
||||
func HelpMessage() string {
|
||||
//line assets/assets.qtpl:3
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:3
|
||||
WriteHelpMessage(qb422016)
|
||||
//line assets/assets.qtpl:3
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:3
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:3
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:3
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:5
|
||||
func StreamExampleConfig(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:6
|
||||
qw422016.N().S(`WikiName = My wiki
|
||||
NaviTitleIcon = 🐑
|
||||
|
||||
[Hyphae]
|
||||
HomeHypha = home
|
||||
UserHypha = u
|
||||
HeaderLinksHypha = header-links
|
||||
|
||||
[Network]
|
||||
HTTPPort = 8080
|
||||
URL = https://wiki
|
||||
GeminiCertificatePath = /home/wiki/gemcerts
|
||||
|
||||
[Authorization]
|
||||
UseFixedAuth = true
|
||||
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
||||
`)
|
||||
//line assets/assets.qtpl:6
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:2
|
||||
//line assets/assets.qtpl:7
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:7
|
||||
func WriteExampleConfig(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:7
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:7
|
||||
StreamExampleConfig(qw422016)
|
||||
//line assets/assets.qtpl:7
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:7
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:7
|
||||
func ExampleConfig() string {
|
||||
//line assets/assets.qtpl:7
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:7
|
||||
WriteExampleConfig(qb422016)
|
||||
//line assets/assets.qtpl:7
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:7
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:7
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:7
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:9
|
||||
func StreamDefaultCSS(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:9
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:10
|
||||
qw422016.N().S(`.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; }
|
||||
.upload-binary__input { display: block; margin: .25rem 0; }
|
||||
|
||||
@ -298,168 +384,168 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; }
|
||||
|
||||
.backlinks { display: none; }
|
||||
`)
|
||||
//line assets/assets.qtpl:2
|
||||
//line assets/assets.qtpl:10
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
func WriteDefaultCSS(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
StreamDefaultCSS(qw422016)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
func DefaultCSS() string {
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
WriteDefaultCSS(qb422016)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:3
|
||||
//line assets/assets.qtpl:11
|
||||
}
|
||||
|
||||
// Next three are from https://remixicon.com/
|
||||
|
||||
//line assets/assets.qtpl:6
|
||||
//line assets/assets.qtpl:14
|
||||
func StreamIconHTTP(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:6
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:7
|
||||
//line assets/assets.qtpl:15
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:7
|
||||
//line assets/assets.qtpl:15
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
func WriteIconHTTP(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
StreamIconHTTP(qw422016)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
func IconHTTP() string {
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
WriteIconHTTP(qb422016)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:8
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:10
|
||||
//line assets/assets.qtpl:18
|
||||
func StreamIconGemini(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:10
|
||||
//line assets/assets.qtpl:18
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:11
|
||||
//line assets/assets.qtpl:19
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M15.502 20A6.523 6.523 0 0 1 12 23.502 6.523 6.523 0 0 1 8.498 20h2.26c.326.489.747.912 1.242 1.243.495-.33.916-.754 1.243-1.243h2.259zM18 14.805l2 2.268V19H4v-1.927l2-2.268V9c0-3.483 2.504-6.447 6-7.545C15.496 2.553 18 5.517 18 9v5.805zM17.27 17L16 15.56V9c0-2.318-1.57-4.43-4-5.42C9.57 4.57 8 6.681 8 9v6.56L6.73 17h10.54zM12 11a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:11
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:12
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:12
|
||||
func WriteIconGemini(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:12
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:12
|
||||
StreamIconGemini(qw422016)
|
||||
//line assets/assets.qtpl:12
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:12
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:12
|
||||
func IconGemini() string {
|
||||
//line assets/assets.qtpl:12
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:12
|
||||
WriteIconGemini(qb422016)
|
||||
//line assets/assets.qtpl:12
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:12
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:12
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:12
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:14
|
||||
func StreamIconMailto(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:15
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm17 4.238l-7.928 7.1L4 7.216V19h16V7.238zM4.511 5l7.55 6.662L19.502 5H4.511z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:15
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:16
|
||||
func WriteIconMailto(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:16
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:16
|
||||
StreamIconMailto(qw422016)
|
||||
//line assets/assets.qtpl:16
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:16
|
||||
func IconMailto() string {
|
||||
//line assets/assets.qtpl:16
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:16
|
||||
WriteIconMailto(qb422016)
|
||||
//line assets/assets.qtpl:16
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:16
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:16
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
// This is a modified version of https://www.svgrepo.com/svg/232085/rat
|
||||
|
||||
//line assets/assets.qtpl:19
|
||||
func StreamIconGopher(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:19
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:20
|
||||
func WriteIconGemini(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:20
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:20
|
||||
StreamIconGemini(qw422016)
|
||||
//line assets/assets.qtpl:20
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:20
|
||||
func IconGemini() string {
|
||||
//line assets/assets.qtpl:20
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:20
|
||||
WriteIconGemini(qb422016)
|
||||
//line assets/assets.qtpl:20
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:20
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:20
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:22
|
||||
func StreamIconMailto(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:22
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:23
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm17 4.238l-7.928 7.1L4 7.216V19h16V7.238zM4.511 5l7.55 6.662L19.502 5H4.511z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:23
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:24
|
||||
func WriteIconMailto(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:24
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:24
|
||||
StreamIconMailto(qw422016)
|
||||
//line assets/assets.qtpl:24
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:24
|
||||
func IconMailto() string {
|
||||
//line assets/assets.qtpl:24
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:24
|
||||
WriteIconMailto(qb422016)
|
||||
//line assets/assets.qtpl:24
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:24
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:24
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
// This is a modified version of https://www.svgrepo.com/svg/232085/rat
|
||||
|
||||
//line assets/assets.qtpl:27
|
||||
func StreamIconGopher(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:27
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:28
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16">
|
||||
<path fill="#999" d="M447.238,204.944v-70.459c0-8.836-7.164-16-16-16c-34.051,0-64.414,21.118-75.079,55.286
|
||||
C226.094,41.594,0,133.882,0,319.435c0,0.071,0.01,0.14,0.011,0.21c0.116,44.591,36.423,80.833,81.04,80.833h171.203
|
||||
@ -472,34 +558,34 @@ c55.425-8.382,107.014,29.269,115.759,84.394H295.484z"/>
|
||||
<circle fill="#999" cx="415.238" cy="260.05" r="21.166"/>
|
||||
</svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:20
|
||||
//line assets/assets.qtpl:28
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
func WriteIconGopher(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
StreamIconGopher(qw422016)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
func IconGopher() string {
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
WriteIconGopher(qb422016)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:21
|
||||
//line assets/assets.qtpl:29
|
||||
}
|
||||
|
24
flag.go
24
flag.go
@ -2,13 +2,18 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/assets"
|
||||
"github.com/bouncepaw/mycorrhiza/user"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
var printExampleConfig bool
|
||||
|
||||
func init() {
|
||||
// flag.StringVar(&util.URL, "url", "http://0.0.0.0:$port", "URL at which your wiki can be found. Used to generate feeds and social media previews")
|
||||
// flag.StringVar(&util.ServerPort, "port", "1737", "Port to serve the wiki at using HTTP")
|
||||
@ -21,6 +26,15 @@ func init() {
|
||||
// flag.StringVar(&util.HeaderLinksHypha, "header-links-hypha", "", "Optional hypha that overrides the header links")
|
||||
// flag.StringVar(&util.GeminiCertPath, "gemini-cert-path", "", "Directory where you store Gemini certificates. Leave empty if you don't want to use Gemini.")
|
||||
flag.StringVar(&util.ConfigFilePath, "config-path", "", "Path to a configuration file. Leave empty if you don't want to use it.")
|
||||
flag.BoolVar(&printExampleConfig, "print-example-config", false, "If true, print an example configuration file contents and exit. You can save the output to a file and base your own configuration on it.")
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(
|
||||
flag.CommandLine.Output(),
|
||||
assets.HelpMessage(),
|
||||
os.Args[0],
|
||||
)
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
}
|
||||
|
||||
// Do the things related to cli args and die maybe
|
||||
@ -28,13 +42,17 @@ func parseCliArgs() {
|
||||
flag.Parse()
|
||||
|
||||
args := flag.Args()
|
||||
if printExampleConfig {
|
||||
fmt.Printf(assets.ExampleConfig())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
log.Fatal("Error: pass a wiki directory")
|
||||
}
|
||||
|
||||
if util.ConfigFilePath != "" {
|
||||
util.ReadConfigFile(util.ConfigFilePath)
|
||||
}
|
||||
// It is ok if the path is ""
|
||||
util.ReadConfigFile(util.ConfigFilePath)
|
||||
|
||||
var err error
|
||||
WikiDir, err = filepath.Abs(args[0])
|
||||
|
@ -13,11 +13,22 @@ import (
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
// Path to git executable. Set at init()
|
||||
var gitpath string
|
||||
|
||||
var renameMsgPattern = regexp.MustCompile(`^Rename ‘(.*)’ to ‘.*’`)
|
||||
|
||||
// Start initializes git credentials.
|
||||
// Start finds git and initializes git credentials.
|
||||
func Start(wikiDir string) {
|
||||
_, err := gitsh("config", "user.name", "wikimind")
|
||||
path, err := exec.LookPath("git")
|
||||
if err != nil {
|
||||
log.Fatal("Cound not find the git executable. Check your $PATH.")
|
||||
} else {
|
||||
log.Println("Git path is", path)
|
||||
}
|
||||
gitpath = path
|
||||
|
||||
_, err = gitsh("config", "user.name", "wikimind")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -110,20 +121,6 @@ func (rev *Revision) bestLink() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Path to git executable. Set at init()
|
||||
var gitpath string
|
||||
|
||||
func init() {
|
||||
path, err := exec.LookPath("git")
|
||||
if err != nil {
|
||||
log.Fatal("Cound not find the git executable. Check your $PATH.")
|
||||
} else {
|
||||
log.Println("Git path is", path)
|
||||
}
|
||||
gitpath = path
|
||||
|
||||
}
|
||||
|
||||
// I pronounce it as [gɪt͡ʃ].
|
||||
// gitsh is async-safe, therefore all other git-related functions in this module are too.
|
||||
func gitsh(args ...string) (out bytes.Buffer, err error) {
|
||||
|
2
main.go
2
main.go
@ -168,8 +168,8 @@ Crawl-delay: 5`))
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Println("Running MycorrhizaWiki β")
|
||||
parseCliArgs()
|
||||
log.Println("Running MycorrhizaWiki β")
|
||||
if err := os.Chdir(WikiDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ type Authorization struct {
|
||||
}
|
||||
|
||||
func ReadConfigFile(path string) {
|
||||
log.Println("Loading config at", path)
|
||||
cfg := &Config{
|
||||
WikiName: "MycorrhizaWiki",
|
||||
NaviTitleIcon: "🍄",
|
||||
@ -52,9 +51,13 @@ func ReadConfigFile(path string) {
|
||||
FixedAuthCredentialsPath: "",
|
||||
},
|
||||
}
|
||||
err := ini.MapTo(cfg, path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
if path != "" {
|
||||
log.Println("Loading config at", path)
|
||||
err := ini.MapTo(cfg, path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
SiteName = cfg.WikiName
|
||||
|
Loading…
Reference in New Issue
Block a user