Skip to content

Commit 78b6945

Browse files
committed
Add a lowercase version of --logLevel (bsc#1243611)
Users are sometimes misreading the --logLevel and type --loglevel. Add this one as a hidden alternative.
1 parent 0734dbd commit 78b6945

7 files changed

Lines changed: 29 additions & 4 deletions

File tree

mgradm/cmd/cmd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ func NewUyuniadmCommand() (*cobra.Command, error) {
7474
rootCmd.PersistentFlags().StringVar(&globalFlags.LogLevel, "logLevel", "",
7575
L("application log level")+"(trace|debug|info|warn|error|fatal|panic)",
7676
)
77+
rootCmd.PersistentFlags().StringVar(&globalFlags.LogLevel, "loglevel", "",
78+
L("application log level")+"(trace|debug|info|warn|error|fatal|panic)",
79+
)
80+
if err := rootCmd.PersistentFlags().MarkHidden("loglevel"); err != nil {
81+
return rootCmd, err
82+
}
7783

7884
migrateCmd := migrate.NewCommand(globalFlags)
7985
rootCmd.AddCommand(migrateCmd)

mgradm/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 SUSE LLC
1+
// SPDX-FileCopyrightText: 2025 SUSE LLC
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

@@ -8,6 +8,7 @@ import (
88
"os"
99

1010
"github.com/chai2010/gettext-go"
11+
"github.com/spf13/cobra"
1112
"github.com/uyuni-project/uyuni-tools/mgradm/cmd"
1213
l10n_utils "github.com/uyuni-project/uyuni-tools/shared/l10n/utils"
1314
"github.com/uyuni-project/uyuni-tools/shared/utils"
@@ -16,6 +17,7 @@ import (
1617
// Run runs the `mgradm` root command.
1718
func Run() error {
1819
gettext.BindLocale(gettext.New("mgradm", utils.LocaleRoot, l10n_utils.New(utils.LocaleRoot)))
20+
cobra.EnableCaseInsensitive = true
1921
run, err := cmd.NewUyuniadmCommand()
2022
if err != nil {
2123
return err

mgrctl/cmd/cmd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 SUSE LLC
1+
// SPDX-FileCopyrightText: 2025 SUSE LLC
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

@@ -39,6 +39,12 @@ func NewUyunictlCommand() *cobra.Command {
3939
rootCmd.PersistentFlags().StringVar(&globalFlags.LogLevel, "logLevel", "",
4040
L("application log level")+"(trace|debug|info|warn|error|fatal|panic)",
4141
)
42+
rootCmd.PersistentFlags().StringVar(&globalFlags.LogLevel, "loglevel", "",
43+
L("application log level")+"(trace|debug|info|warn|error|fatal|panic)",
44+
)
45+
if err := rootCmd.PersistentFlags().MarkHidden("loglevel"); err != nil {
46+
log.Warn().Err(err).Msg(L("failed to mark --loglevel option as hidden"))
47+
}
4248

4349
rootCmd.PersistentPreRun = func(cmd *cobra.Command, _ []string) {
4450
// do not log if running the completion cmd as the output is redirect to create a file to source

mgrctl/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 SUSE LLC
1+
// SPDX-FileCopyrightText: 2025 SUSE LLC
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

@@ -8,6 +8,7 @@ import (
88
"os"
99

1010
"github.com/chai2010/gettext-go"
11+
"github.com/spf13/cobra"
1112
"github.com/uyuni-project/uyuni-tools/mgrctl/cmd"
1213
l10n_utils "github.com/uyuni-project/uyuni-tools/shared/l10n/utils"
1314
"github.com/uyuni-project/uyuni-tools/shared/utils"
@@ -16,6 +17,7 @@ import (
1617
// Run runs the `mgrctl` root command.
1718
func Run() error {
1819
gettext.BindLocale(gettext.New("mgrctl", utils.LocaleRoot, l10n_utils.New(utils.LocaleRoot)))
20+
cobra.EnableCaseInsensitive = true
1921
run := cmd.NewUyunictlCommand()
2022

2123
return run.Execute()

mgrpxy/cmd/cmd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func NewUyuniproxyCommand() (*cobra.Command, error) {
6868
rootCmd.PersistentFlags().StringVar(&globalFlags.LogLevel, "logLevel", "",
6969
L("application log level")+"(trace|debug|info|warn|error|fatal|panic)",
7070
)
71+
rootCmd.PersistentFlags().StringVar(&globalFlags.LogLevel, "loglevel", "",
72+
L("application log level")+"(trace|debug|info|warn|error|fatal|panic)",
73+
)
74+
if err := rootCmd.PersistentFlags().MarkHidden("loglevel"); err != nil {
75+
return rootCmd, err
76+
}
7177

7278
installCmd := install.NewCommand(globalFlags)
7379
rootCmd.AddCommand(installCmd)

mgrpxy/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 SUSE LLC
1+
// SPDX-FileCopyrightText: 2025 SUSE LLC
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

@@ -8,6 +8,7 @@ import (
88
"os"
99

1010
"github.com/chai2010/gettext-go"
11+
"github.com/spf13/cobra"
1112
"github.com/uyuni-project/uyuni-tools/mgrpxy/cmd"
1213
l10n_utils "github.com/uyuni-project/uyuni-tools/shared/l10n/utils"
1314
"github.com/uyuni-project/uyuni-tools/shared/utils"
@@ -16,6 +17,7 @@ import (
1617
// Run runs the `mgrpxy` root command.
1718
func Run() error {
1819
gettext.BindLocale(gettext.New("mgrpxy", utils.LocaleRoot, l10n_utils.New(utils.LocaleRoot)))
20+
cobra.EnableCaseInsensitive = true
1921
run, err := cmd.NewUyuniproxyCommand()
2022
if err != nil {
2123
return err
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add a lowercase version of --logLevel (bsc#1243611)

0 commit comments

Comments
 (0)