You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
549 B
34 lines
549 B
package main |
|
|
|
import ( |
|
"os" |
|
|
|
"github.com/spf13/cobra" |
|
) |
|
|
|
// Command |
|
var envCmd = &cobra.Command{ |
|
Use: "env", |
|
Short: "generates environment variables for shell scripts", |
|
RunE: func(_ *cobra.Command, _ []string) error { |
|
m, err := cfg.LoadZones(false) |
|
if err != nil { |
|
return err |
|
} |
|
|
|
_, err = m.Env(*envExport).WriteTo(os.Stdout) |
|
return err |
|
}, |
|
} |
|
|
|
// Command Flags |
|
var ( |
|
envExport *bool |
|
) |
|
|
|
func init() { |
|
rootCmd.AddCommand(envCmd) |
|
|
|
envExport = envCmd.PersistentFlags().BoolP("export", "e", false, |
|
"export generated variables") |
|
}
|
|
|