feat(BRIDGE-217): added missing parameter to the CLI help command.

This commit is contained in:
Xavier Michelon
2024-10-23 17:12:02 +02:00
parent cb8d1a2389
commit fb523e5573
2 changed files with 57 additions and 29 deletions

View File

@ -75,17 +75,21 @@ const (
flagLogIMAP = "log-imap" flagLogIMAP = "log-imap"
flagLogSMTP = "log-smtp" flagLogSMTP = "log-smtp"
flagEnableKeychainTest = "enable-keychain-test"
flagDisableKeychainTest = "disable-keychain-test"
flagSoftwareRenderer = "software-renderer"
flagSetSoftwareRenderer = "set-software-renderer"
flagSetHardwareRenderer = "set-hardware-renderer"
) )
// Hidden flags. // Hidden flags.
const ( const (
flagLauncher = "launcher" flagLauncher = "launcher"
flagNoWindow = "no-window" flagNoWindow = "no-window"
flagParentPID = "parent-pid" flagParentPID = "parent-pid"
flagSoftwareRenderer = "software-renderer" FlagSessionID = "session-id"
flagEnableKeychainTest = "enable-keychain-test"
flagDisableKeychainTest = "disable-keychain-test"
FlagSessionID = "session-id"
) )
const ( const (
@ -94,17 +98,17 @@ const (
) )
var cliFlagEnableKeychainTest = &cli.BoolFlag{ //nolint:gochecknoglobals var cliFlagEnableKeychainTest = &cli.BoolFlag{ //nolint:gochecknoglobals
Name: flagEnableKeychainTest, Name: flagEnableKeychainTest,
Usage: "Enable the keychain test", Usage: "Enable the keychain test for the current and future executions of the application",
Hidden: true, Value: false,
Value: false, DisableDefaultText: true,
} //nolint:gochecknoglobals } //nolint:gochecknoglobals
var cliFlagDisableKeychainTest = &cli.BoolFlag{ //nolint:gochecknoglobals var cliFlagDisableKeychainTest = &cli.BoolFlag{ //nolint:gochecknoglobals
Name: flagDisableKeychainTest, Name: flagDisableKeychainTest,
Usage: "Disable the keychain test", Usage: "Disable the keychain test for the current and future executions of the application",
Hidden: true, Value: false,
Value: false, DisableDefaultText: true,
} }
func New() *cli.App { func New() *cli.App {
@ -156,6 +160,24 @@ func New() *cli.App {
Name: flagLogSMTP, Name: flagLogSMTP,
Usage: "Enable logging of SMTP communications (may contain decrypted data!)", Usage: "Enable logging of SMTP communications (may contain decrypted data!)",
}, },
&cli.BoolFlag{
Name: flagSoftwareRenderer, // This flag is ignored by bridge, but should be passed to launcher in case of restart, so it need to be accepted by the CLI parser.
Usage: "Use software rendering of the GUI for the current execution of the application",
Value: false,
DisableDefaultText: true,
},
&cli.BoolFlag{
Name: flagSetSoftwareRenderer, // This flag is ignored by bridge, we just want it to be shown in the help (BRIDGE-217).
Usage: "Toggle software rendering of the GUI for the current and future executions of the application",
Value: false,
DisableDefaultText: true,
},
&cli.BoolFlag{
Name: flagSetHardwareRenderer, // This flag is ignored by bridge, we just want it to be shown in the help (BRIDGE-217).
Usage: "Toggle hardware rendering of the GUI for the current and future executions of the application",
Value: false,
DisableDefaultText: true,
},
// Hidden flags // Hidden flags
&cli.BoolFlag{ &cli.BoolFlag{
@ -174,19 +196,22 @@ func New() *cli.App {
Hidden: true, Hidden: true,
Value: -1, Value: -1,
}, },
&cli.BoolFlag{
Name: flagSoftwareRenderer, // This flag is ignored by bridge, but should be passed to launcher in case of restart, so it need to be accepted by the CLI parser.
Usage: "GUI is using software renderer",
Hidden: true,
Value: false,
},
&cli.StringFlag{ &cli.StringFlag{
Name: FlagSessionID, Name: FlagSessionID,
Hidden: true, Hidden: true,
}, },
// the two flags below were introduced by BRIDGE-116 }
cliFlagEnableKeychainTest,
cliFlagDisableKeychainTest, // We override the default help value because we want "Show" to be capitalized
cli.HelpFlag = &cli.BoolFlag{
Name: "help",
Usage: "Show help",
DisableDefaultText: true,
}
if onMacOS() {
// The two flags below were introduced for BRIDGE-116, and are available only on macOS.
app.Flags = append(app.Flags, cliFlagEnableKeychainTest, cliFlagDisableKeychainTest)
} }
app.Action = run app.Action = run
@ -548,7 +573,7 @@ func setDeviceCookies(jar *cookies.Jar) error {
} }
func checkSkipKeychainTest(c *cli.Context, settingsDir string) bool { func checkSkipKeychainTest(c *cli.Context, settingsDir string) bool {
if runtime.GOOS != "darwin" { if !onMacOS() {
return false return false
} }
@ -578,3 +603,7 @@ func checkSkipKeychainTest(c *cli.Context, settingsDir string) bool {
return skip return skip
} }
func onMacOS() bool {
return runtime.GOOS == "darwin"
}

View File

@ -18,7 +18,6 @@
package app package app
import ( import (
"runtime"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -44,12 +43,12 @@ func TestCheckSkipKeychainTest(t *testing.T) {
disableArgs := []string{"appName", "-" + flagDisableKeychainTest} disableArgs := []string{"appName", "-" + flagDisableKeychainTest}
bothArgs := []string{"appName", "-" + flagDisableKeychainTest, "-" + flagEnableKeychainTest} bothArgs := []string{"appName", "-" + flagDisableKeychainTest, "-" + flagEnableKeychainTest}
const trueOnlyOnMac = runtime.GOOS == "darwin" onMac := onMacOS()
expectedResult = false expectedResult = false
require.NoError(t, app.Run(noArgs)) require.NoError(t, app.Run(noArgs))
expectedResult = trueOnlyOnMac expectedResult = onMac
require.NoError(t, app.Run(disableArgs)) require.NoError(t, app.Run(disableArgs))
require.NoError(t, app.Run(noArgs)) require.NoError(t, app.Run(noArgs))
@ -57,7 +56,7 @@ func TestCheckSkipKeychainTest(t *testing.T) {
require.NoError(t, app.Run(enableArgs)) require.NoError(t, app.Run(enableArgs))
require.NoError(t, app.Run(noArgs)) require.NoError(t, app.Run(noArgs))
expectedResult = trueOnlyOnMac expectedResult = onMac
require.NoError(t, app.Run(disableArgs)) require.NoError(t, app.Run(disableArgs))
expectedResult = false expectedResult = false