✨ Move CLI commands to cli/ package for extensibility
- Rename internal/cmd/ to cli/ - Export commands: RootCmd, DropCmd, ConfigCmd - Enable custom app creation by importing cli package
This commit is contained in:
parent
5c8e2fc607
commit
8c23375208
4 changed files with 22 additions and 41 deletions
41
cli/root.go
Normal file
41
cli/root.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Copyright © 2024 Dan Jones <danjones@goodevilgenius.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"codeberg.org/danjones000/my-log/config"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "my-log",
|
||||
Short: "A brief description of your application",
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
err := RootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.PersistentFlags().StringVarP(&config.ConfigPath, "config", "c", config.ConfigPath, "config file")
|
||||
RootCmd.PersistentFlags().StringToStringVarP(&config.Overrides, "config-value", "v", config.Overrides, "Override config values. Use dot syntax to specify key. E.g. -v output.stdout.config.format=json")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue