mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
* Move to using a custom argument list in main for the provider, now that we have argument handling.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
// This file is Free Software under the MIT License
|
|
// without warranty, see README.md and LICENSES/MIT.txt for details.
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
//
|
|
// SPDX-FileCopyrightText: 2021 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
|
|
// Software-Engineering: 2021 Intevation GmbH <https://intevation.de>
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http/cgi"
|
|
"os"
|
|
|
|
"github.com/csaf-poc/csaf_distribution/util"
|
|
"github.com/jessevdk/go-flags"
|
|
)
|
|
|
|
type options struct {
|
|
Version bool `long:"version" description:"Display version of the binary"`
|
|
}
|
|
|
|
func realMain(args []string) {
|
|
cfg, err := loadConfig()
|
|
if err != nil {
|
|
log.Fatalf("error: %v\n", err)
|
|
}
|
|
|
|
var opts options
|
|
parser := flags.NewParser(&opts, flags.Default)
|
|
parser.ParseArgs(args)
|
|
if opts.Version {
|
|
fmt.Println(util.SemVersion)
|
|
return
|
|
}
|
|
|
|
c, err := newController(cfg)
|
|
if err != nil {
|
|
log.Fatalf("error: %v\n", err)
|
|
}
|
|
pim := newPathInfoMux()
|
|
c.bind(pim)
|
|
|
|
if err := cgi.Serve(pim); err != nil {
|
|
log.Fatalf("error: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
realMain(os.Args[1:])
|
|
}
|