diff options
author | Alan Pearce | 2024-05-20 18:13:07 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-20 18:13:07 +0200 |
commit | 0f5508013d776f8806a87957f80e74c7f74c72eb (patch) | |
tree | 1d7b9bbe1b296d08d2ca9e740dc546cccaf4e1df /internal/config/config.go | |
parent | d0c2de9e762fb476b5cb53bb5129bf8af8cb9b45 (diff) | |
download | searchix-0f5508013d776f8806a87957f80e74c7f74c72eb.tar.lz searchix-0f5508013d776f8806a87957f80e74c7f74c72eb.tar.zst searchix-0f5508013d776f8806a87957f80e74c7f74c72eb.zip |
feat(config): print durations and URLs with human values
Diffstat (limited to 'internal/config/config.go')
-rw-r--r-- | internal/config/config.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 939d7b1..3947d18 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -21,6 +21,10 @@ type URL struct { *url.URL } +func (u *URL) MarshalText() ([]byte, error) { + return []byte(u.URL.String()), nil +} + func (u *URL) UnmarshalText(text []byte) (err error) { u.URL, err = url.Parse(string(text)) @@ -35,6 +39,10 @@ type Duration struct { time.Duration } +func (d *Duration) MarshalText() ([]byte, error) { + return []byte(d.Duration.String()), nil +} + func (d *Duration) UnmarshalText(text []byte) (err error) { d.Duration, err = time.ParseDuration(string(text)) if err != nil { @@ -122,8 +130,8 @@ var defaultConfig = Config{ ImportPath: "nixos/release.nix", Attribute: "options", OutputPath: "share/doc/nixos", - FetchTimeout: 5 * time.Minute, - ImportTimeout: 15 * time.Minute, + FetchTimeout: Duration{5 * time.Minute}, + ImportTimeout: Duration{15 * time.Minute}, Repo: nixpkgs, }, "darwin": { @@ -137,8 +145,8 @@ var defaultConfig = Config{ ImportPath: "release.nix", Attribute: "options", OutputPath: "share/doc/darwin", - FetchTimeout: 5 * time.Minute, - ImportTimeout: 15 * time.Minute, + FetchTimeout: Duration{5 * time.Minute}, + ImportTimeout: Duration{15 * time.Minute}, Repo: Repository{ Type: "github", Owner: "LnL7", @@ -156,8 +164,8 @@ var defaultConfig = Config{ ImportPath: "default.nix", Attribute: "docs.json", OutputPath: "share/doc/home-manager", - FetchTimeout: 5 * time.Minute, - ImportTimeout: 15 * time.Minute, + FetchTimeout: Duration{5 * time.Minute}, + ImportTimeout: Duration{15 * time.Minute}, Repo: Repository{ Type: "github", Owner: "nix-community", @@ -172,8 +180,8 @@ var defaultConfig = Config{ Fetcher: ChannelNixpkgs, Channel: "nixos-unstable", OutputPath: "packages.json.br", - FetchTimeout: 5 * time.Minute, - ImportTimeout: 15 * time.Minute, + FetchTimeout: Duration{5 * time.Minute}, + ImportTimeout: Duration{15 * time.Minute}, Repo: nixpkgs, }, }, |