diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 27 |
1 files changed, 11 insertions, 16 deletions
@@ -5,7 +5,6 @@ package main | |||
5 | import ( | 5 | import ( |
6 | "embed" | 6 | "embed" |
7 | "fmt" | 7 | "fmt" |
8 | "io/fs" | ||
9 | "log" | 8 | "log" |
10 | 9 | ||
11 | "code.crute.us/mcrute/ssh-proxy/app" | 10 | "code.crute.us/mcrute/ssh-proxy/app" |
@@ -14,6 +13,7 @@ import ( | |||
14 | "code.crute.us/mcrute/ssh-proxy/cmd/web" | 13 | "code.crute.us/mcrute/ssh-proxy/cmd/web" |
15 | 14 | ||
16 | "code.crute.us/mcrute/golib/cli" | 15 | "code.crute.us/mcrute/golib/cli" |
16 | "code.crute.us/mcrute/golib/fs" | ||
17 | 17 | ||
18 | "github.com/spf13/cobra" | 18 | "github.com/spf13/cobra" |
19 | 19 | ||
@@ -23,30 +23,25 @@ import ( | |||
23 | ) | 23 | ) |
24 | 24 | ||
25 | //go:embed templates | 25 | //go:embed templates |
26 | var embeddedTemplates embed.FS | 26 | var templates embed.FS |
27 | 27 | ||
28 | //go:embed clients | 28 | //go:embed clients |
29 | var embeddedClients embed.FS | 29 | var clients embed.FS |
30 | 30 | ||
31 | var appVersion string | 31 | var version string |
32 | 32 | ||
33 | func main() { | 33 | func main() { |
34 | rootCmd := &cobra.Command{ | 34 | r := &cobra.Command{ |
35 | Use: "web-server", | 35 | Use: "web-server", |
36 | Short: fmt.Sprintf("SSH proxy web server (version %s)", appVersion), | 36 | Short: fmt.Sprintf("SSH proxy web server (version %s)", version), |
37 | } | 37 | } |
38 | cli.AddFlags(rootCmd, &app.Config{}, app.DefaultConfig, "") | 38 | cli.AddFlags(r, &app.Config{}, app.DefaultConfig, "") |
39 | 39 | ||
40 | templates, err := fs.Sub(embeddedTemplates, "templates") | 40 | web.Register(r, fs.MustSub(templates, "templates"), clients, version) |
41 | if err != nil { | 41 | client.Register(r, version) |
42 | log.Fatalf("Error building sub-fs of embeded fs") | 42 | register.Register(r) |
43 | } | ||
44 | |||
45 | web.Register(rootCmd, templates, embeddedClients, appVersion) | ||
46 | client.Register(rootCmd, appVersion) | ||
47 | register.Register(rootCmd) | ||
48 | 43 | ||
49 | if err := rootCmd.Execute(); err != nil { | 44 | if err := r.Execute(); err != nil { |
50 | log.Fatalf("Error running root command: %s", err) | 45 | log.Fatalf("Error running root command: %s", err) |
51 | } | 46 | } |
52 | } | 47 | } |