chore: restrict custom templates by command (#27297)
This commit is contained in:
parent
3b374f7795
commit
9a9527d224
8 changed files with 20 additions and 7 deletions
14
cmd/root.go
14
cmd/root.go
|
|
@ -80,17 +80,14 @@ func init() {
|
|||
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
withCustomTemplate(rootCmd)
|
||||
|
||||
// global options
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "Config file (default \"~/evcc.yaml\" or \"/etc/evcc.yaml\")")
|
||||
rootCmd.PersistentFlags().StringVar(&cfgDatabase, "database", "", "Database location (default \"~/.evcc/evcc.db\")")
|
||||
rootCmd.PersistentFlags().BoolP("help", "h", false, "Help")
|
||||
rootCmd.PersistentFlags().Bool(flagHeaders, false, flagHeadersDescription)
|
||||
rootCmd.PersistentFlags().Bool(flagIgnoreDatabase, false, flagIgnoreDatabaseDescription)
|
||||
rootCmd.PersistentFlags().String(flagTemplate, "", flagTemplateDescription)
|
||||
rootCmd.PersistentFlags().String(flagTemplateType, "", flagTemplateTypeDescription)
|
||||
|
||||
rootCmd.Flags().Bool(flagDemoMode, false, flagDemoModeDescription)
|
||||
rootCmd.Flags().StringVar(&customCssFile, flagCustomCss, "", flagCustomCssDescription)
|
||||
|
||||
// config file options
|
||||
rootCmd.PersistentFlags().StringP("log", "l", "info", "Log level (fatal, error, warn, info, debug, trace)")
|
||||
|
|
@ -106,6 +103,8 @@ func init() {
|
|||
bind(rootCmd, "mcp")
|
||||
|
||||
rootCmd.Flags().Bool(flagDisableAuth, false, flagDisableAuthDescription)
|
||||
rootCmd.Flags().Bool(flagDemoMode, false, flagDemoModeDescription)
|
||||
rootCmd.Flags().StringVar(&customCssFile, flagCustomCss, "", flagCustomCssDescription)
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set
|
||||
|
|
@ -138,6 +137,11 @@ func Execute() {
|
|||
}
|
||||
}
|
||||
|
||||
func withCustomTemplate(cmd *cobra.Command) {
|
||||
cmd.Flags().String(flagTemplate, "", flagTemplateDescription)
|
||||
cmd.Flags().String(flagTemplateType, "", flagTemplateTypeDescription)
|
||||
}
|
||||
|
||||
func allowCtrlC(cmd *cobra.Command, args []string) {
|
||||
if cmd.Name() == rootName {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue