aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-01-11 16:20:07 -0800
committerChristine Dodrill <me@christine.website>2019-01-11 16:20:07 -0800
commita45639e42caaaace3671ffa530022705582e0ce6 (patch)
treebb00c41c612bac7e08d0d783ddc070895c15ba8a /internal
parent2059adef99a8ca2ed4b0264cd19f84a9cb9e4420 (diff)
downloadx-a45639e42caaaace3671ffa530022705582e0ce6.tar.xz
x-a45639e42caaaace3671ffa530022705582e0ce6.zip
add config support
Diffstat (limited to 'internal')
-rw-r--r--internal/internal.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/internal/internal.go b/internal/internal.go
index f21624e..46eeaaf 100644
--- a/internal/internal.go
+++ b/internal/internal.go
@@ -1,19 +1,23 @@
package internal
import (
+ "context"
"encoding/json"
"flag"
"fmt"
- "log"
"net/http"
"os"
+ "github.com/Xe/ln"
+ "github.com/Xe/ln/opname"
"github.com/Xe/x/tools/license/licenses"
"go4.org/legal"
+ "within.website/confyg/flagconfyg"
)
var (
licenseShow = flag.Bool("license", false, "show software license?")
+ config = flag.String("config", "", "configuration file, if set")
)
func init() {
@@ -25,10 +29,14 @@ func init() {
})
}
-// HandleLicense optionally shows all software licenses.
-func HandleLicense() {
+// HandleLicense is a wrapper for commands that use HandleLicense.
+func HandleLicense() { HandleStartup() }
+
+// HandleStartup optionally shows all software licenses or other things.
+func HandleStartup() {
+ ctx := opname.With(context.Background(), "internal.HandleStartup")
if *licenseShow {
- log.Printf("Licenses for %v", os.Args)
+ fmt.Printf("Licenses for %v\n", os.Args)
for _, li := range legal.Licenses() {
fmt.Println(li)
@@ -37,4 +45,10 @@ func HandleLicense() {
os.Exit(0)
}
+
+ if *config != "" {
+ ln.Log(ctx, ln.Info("loading config"), ln.F{"path": *config})
+
+ flagconfyg.CmdParse(*config)
+ }
}