diff options
| author | Christine Dodrill <me@christine.website> | 2019-01-11 16:20:07 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2019-01-11 16:20:07 -0800 |
| commit | a45639e42caaaace3671ffa530022705582e0ce6 (patch) | |
| tree | bb00c41c612bac7e08d0d783ddc070895c15ba8a | |
| parent | 2059adef99a8ca2ed4b0264cd19f84a9cb9e4420 (diff) | |
| download | x-a45639e42caaaace3671ffa530022705582e0ce6.tar.xz x-a45639e42caaaace3671ffa530022705582e0ce6.zip | |
add config support
| -rw-r--r-- | go.mod | 1 | ||||
| -rw-r--r-- | go.sum | 2 | ||||
| -rw-r--r-- | internal/internal.go | 22 |
3 files changed, 21 insertions, 4 deletions
@@ -78,5 +78,6 @@ require ( gopkg.in/yaml.v2 v2.2.2 // indirect layeh.com/gopher-json v0.0.0-20181116191917-d3d498bb4913 layeh.com/gopher-luar v1.0.4 // indirect + within.website/confyg v0.0.0-20190112001412-39eaf7bce89f within.website/ln v0.3.0 ) @@ -187,5 +187,7 @@ layeh.com/gopher-json v0.0.0-20181116191917-d3d498bb4913 h1:7GSXubN0n2gOZFLkm72e layeh.com/gopher-json v0.0.0-20181116191917-d3d498bb4913/go.mod h1:ivKkcY8Zxw5ba0jldhZCYYQfGdb2K6u9tbYK1AwMIBc= layeh.com/gopher-luar v1.0.4 h1:BFgt94J/CXh4HkDcE2b7A7pBaVeQKEVfHEBRKL/K/Tc= layeh.com/gopher-luar v1.0.4/go.mod h1:N3rev/ttQd8yVluXaYsa0M/eknzRYWe+pxZ35ZFmaaI= +within.website/confyg v0.0.0-20190112001412-39eaf7bce89f h1:bYKewlpJbGbYWiwTOHnZE49KBDwlN1BSTcvTm6UMF40= +within.website/confyg v0.0.0-20190112001412-39eaf7bce89f/go.mod h1:qKxglCn43FmpkxdqnoLAPXs21JY1vgQfeeaZ/ovKtEE= within.website/ln v0.3.0 h1:2sJx53horlaU5O5a9rG2GqVgmEeDVdDToJjjLOJscIU= within.website/ln v0.3.0/go.mod h1:lF4Q6pUKfkSNFTzujDrjiUQtTQE8XwyTVzGcP5JcCig= 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) + } } |
