Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCalledCommand ¶
Returns the cobra command called, e.g. new or install and also the fully formatted command as passed with arguments/flags. Idea borrowed from carolynvs/porter: https://github.com/carolynvs/porter/blob/ccca10a63627e328616c1006600153da8411a438/cmd/porter/main.go
Types ¶
type RootCommand ¶
type RootCommand[Config tympan.Configurable] struct { ConfigFile string LogLevel string Format string Tympan tympan.Tympan[Config] }
RootCommand contains all the necessary information to initialize a Tympan application
func (*RootCommand[Config]) CreateCommand ¶
func (r *RootCommand[Config]) CreateCommand() *cobra.Command
CreateCommand instatiates the root cobra command of a Tympan app. All other commands are inherited from this one. The root command is where overridable application-wide behavior is implemented; it allows a user to pass the --config flag to specify their own configuration file instead of the default one, the --log-level flag to tune the verbosity of the application, and the --format flag to choose between human readable and JSON output.
It also uses the Tympan Metadata to fill out the root commands use, short name, and long name.
func (*RootCommand[Config]) InitConfig ¶
func (r *RootCommand[Config]) InitConfig()
Initializes the applications configuration (including both the shared configuration from Tympan and the application developer's specified configuration), writing it to disk if it doesn't exist and loading it if it does.
func (*RootCommand[Config]) InitLogger ¶
func (r *RootCommand[Config]) InitLogger()
Configures the zerolog logging for the application, enabling it to be propagated to child commands.
type RootCommander ¶
The Version command is reimplementable and must return a valid cobra Command, initialize logging, and intialize application configuration.