aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-02-17 09:35:44 -0800
committerChristine Dodrill <me@christine.website>2019-02-17 09:35:44 -0800
commit76343ccd100bddcf0921b1fbf20c5d48659d8dc8 (patch)
treef98a6e3f7fb8a55d02d2b0879c60cfba5a4b1594 /internal
parent2511992a18cf4a425aacbdd4d84449ae81b2dbc3 (diff)
downloadx-76343ccd100bddcf0921b1fbf20c5d48659d8dc8.tar.xz
x-76343ccd100bddcf0921b1fbf20c5d48659d8dc8.zip
internal: simplify, kill dead code, split up
Diffstat (limited to 'internal')
-rw-r--r--internal/internal.go41
-rw-r--r--internal/license.go26
2 files changed, 35 insertions, 32 deletions
diff --git a/internal/internal.go b/internal/internal.go
index abf2c7f..b1a7bc4 100644
--- a/internal/internal.go
+++ b/internal/internal.go
@@ -4,12 +4,10 @@ import (
"context"
"flag"
"fmt"
- "net/http"
"os"
"github.com/Xe/x/internal/flagenv"
"github.com/Xe/x/internal/manpage"
- "github.com/Xe/x/tools/license/licenses"
"go4.org/legal"
"within.website/confyg/flagconfyg"
"within.website/ln"
@@ -20,6 +18,9 @@ import (
// Older projects use .env files, shim in compatibility
_ "github.com/joho/godotenv/autoload"
+
+ // User agent init hook
+ _ "github.com/Xe/x/web"
)
var (
@@ -28,25 +29,6 @@ var (
manpageGen = flag.Bool("manpage", false, "generate a manpage template?")
)
-func init() {
- legal.RegisterLicense(licenses.CC0License)
- legal.RegisterLicense(licenses.SQLiteBlessing)
-
- http.HandleFunc("/.within/licenses", func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "Licenses for this program: %s\n", os.Args[0])
-
- for _, li := range legal.Licenses() {
- fmt.Fprintln(w, li)
- fmt.Fprintln(w)
- }
-
- fmt.Fprintln(w, "Be well, Creator.")
- })
-}
-
-// HandleLicense is a wrapper for commands that use HandleLicense.
-func HandleLicense() { HandleStartup() }
-
// HandleStartup optionally shows all software licenses or other things.
// This always loads from the following configuration sources in the following
// order:
@@ -62,7 +44,12 @@ func HandleStartup() {
flag.Parse()
ctx := opname.With(context.Background(), "internal.HandleStartup")
- HandleConfig(ctx)
+ if *config != "" {
+ ln.Log(ctx, ln.Info("loading config"), ln.F{"path": *config})
+
+ flagconfyg.CmdParse(*config)
+ }
+ flag.Parse()
flagenv.Parse()
if *licenseShow {
@@ -80,13 +67,3 @@ func HandleStartup() {
manpage.Spew()
}
}
-
-// HandleConfig handles the config file parsing from -config
-func HandleConfig(ctx context.Context) {
- if *config != "" {
- ln.Log(ctx, ln.Info("loading config"), ln.F{"path": *config})
-
- flagconfyg.CmdParse(*config)
- }
- flag.Parse()
-}
diff --git a/internal/license.go b/internal/license.go
new file mode 100644
index 0000000..7251eec
--- /dev/null
+++ b/internal/license.go
@@ -0,0 +1,26 @@
+package internal
+
+import (
+ "fmt"
+ "net/http"
+ "os"
+
+ "github.com/Xe/x/tools/license/licenses"
+ "go4.org/legal"
+)
+
+func init() {
+ legal.RegisterLicense(licenses.CC0License)
+ legal.RegisterLicense(licenses.SQLiteBlessing)
+
+ http.HandleFunc("/.within/licenses", func(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintf(w, "Licenses for this program: %s\n", os.Args[0])
+
+ for _, li := range legal.Licenses() {
+ fmt.Fprintln(w, li)
+ fmt.Fprintln(w)
+ }
+
+ fmt.Fprintln(w, "Be well, Creator.")
+ })
+}