command

package
v0.0.0-...-bae9420 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: CC0-1.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Root = &cobra.Command{
	Use:  "hidrawmap",
	Args: cobra.ExactArgs(0),
	Run: func(cmd *cobra.Command, args []string) {
		ctx := logger.CtxWithLogger(cmd.Context(), zap.Default().WithLevel(logLevel))
		defer belt.Flush(ctx)

		cfgPath, err := cmd.Flags().GetString("config")
		if err != nil {
			panic(err)
		}
		cfgPath = expandPath(cfgPath)
		var cfg Config
		cfgFile, err := os.Open(cfgPath)
		if err == nil {
			provider, err := config.NewYAML(config.Source(cfgFile))
			if err != nil {
				panic(err)
			}
			provider.Get(config.Root).Populate(&cfg)
			cfgFile.Close()
		} else {
			cfg = ExampleConfig()
			err := ioutil.WriteFile(cfgPath, cfg.Bytes(), 0644)
			if err != nil {
				panic(err)
			}
		}

		err = hidrawmap.New(cfg).Serve(ctx)
		if err != nil {
			panic(err)
		}
	},
}

Functions

This section is empty.

Types

type Config

type Config = hidrawmap.Config

func ExampleConfig

func ExampleConfig() Config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL