diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-12 19:46:40 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-12 19:46:40 +0900 |
| commit | 283bcba05b55acddbb3ffe664e84fda10ed779ad (patch) | |
| tree | 6823333c98c6b9bbf4e4d7ac3b474e1e57e24af2 /config.go | |
| parent | 2e019e48c1c9c5d01c7740797d0c1420888d6872 (diff) | |
fortify/config: flag to print template config serialised as JSON
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -3,6 +3,7 @@ package main import ( "encoding/json" "flag" + "fmt" "os" "git.ophivana.moe/cat/fortify/dbus" @@ -12,6 +13,8 @@ import ( ) var ( + printTemplate bool + confPath string dbusConfigSession string @@ -27,6 +30,8 @@ var ( ) func init() { + flag.BoolVar(&printTemplate, "template", false, "Print a full config template and exit") + // config file, disables every other flag here flag.StringVar(&confPath, "c", "nil", "Path to full app configuration, or \"nil\" to configure from flags") @@ -52,6 +57,18 @@ func init() { flag.StringVar(&launchMethodText, "method", "sudo", methodHelpString) } +func tryTemplate() { + if printTemplate { + if s, err := json.MarshalIndent(app.Template(), "", " "); err != nil { + fatalf("cannot generate template: %v", err) + panic("unreachable") + } else { + fmt.Println(string(s)) + } + os.Exit(0) + } +} + func loadConfig() *app.Config { if confPath == "nil" { // config from flags |
