mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 23:39:56 +01:00
feat(cli): add default value for config option
This commit is contained in:
parent
01e56302f8
commit
4b024af095
@ -27,24 +27,13 @@ var rootCmd = &cobra.Command{
|
|||||||
Source code is available at https://github.com/ansible-semaphore/semaphore.
|
Source code is available at https://github.com/ansible-semaphore/semaphore.
|
||||||
Complete documentation is available at https://ansible-semaphore.com.`,
|
Complete documentation is available at https://ansible-semaphore.com.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if len(args) == 0 && configPath == "" {
|
_ = cmd.Help()
|
||||||
_ = cmd.Help()
|
os.Exit(0)
|
||||||
os.Exit(0)
|
|
||||||
} else {
|
|
||||||
serviceCmd.Run(cmd, args)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
args := os.Args[1:]
|
rootCmd.PersistentFlags().StringVar(&configPath, "config", "/usr/local/etc/semaphore/config.json", "Configuration file path")
|
||||||
if len(args) == 2 && args[0] == "-config" {
|
|
||||||
configPath = args[1]
|
|
||||||
runService()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVar(&configPath, "config", "", "Configuration file path")
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user