From f965d0192282b5c1aa51718606a825c5e2c42092 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 4 Nov 2022 00:53:03 +0100 Subject: [PATCH] Revert "GODT-2013: CLI flag for frontend is required." This reverts commit 4bb29b1b5c8fc4b2179234d2561fc8c4bfa10c57. --- internal/app/base/base.go | 18 +++++---------- internal/app/bridge/bridge.go | 22 ++++++------------- .../frontend/bridge-gui/bridge-gui/main.cpp | 2 +- internal/frontend/frontend.go | 10 ++------- 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/internal/app/base/base.go b/internal/app/base/base.go index f1427f49..f9e86a79 100644 --- a/internal/app/base/base.go +++ b/internal/app/base/base.go @@ -69,13 +69,12 @@ const ( flagMemProfileShort = "m" flagLogLevel = "log-level" flagLogLevelShort = "l" - FlagGRPC = "grpc" // FlagGRPC starts the gRPC frontend - FlagGRPCShort = "g" - FlagCLI = "cli" // FlagCLI indicate to start with command line interface. - flagCLIShort = "c" - flagRestart = "restart" - FlagLauncher = "launcher" - FlagNoWindow = "no-window" + // FlagCLI indicate to start with command line interface. + FlagCLI = "cli" + flagCLIShort = "c" + flagRestart = "restart" + FlagLauncher = "launcher" + FlagNoWindow = "no-window" ) type Base struct { @@ -300,11 +299,6 @@ func (b *Base) NewApp(mainLoop func(*Base, *cli.Context) error) *cli.App { Aliases: []string{flagLogLevelShort}, Usage: "Set the log level (one of panic, fatal, error, warn, info, debug)", }, - &cli.BoolFlag{ - Name: FlagGRPC, - Aliases: []string{FlagGRPCShort}, - Usage: "Start the gRPC service", - }, &cli.BoolFlag{ Name: FlagCLI, Aliases: []string{flagCLIShort}, diff --git a/internal/app/bridge/bridge.go b/internal/app/bridge/bridge.go index 38984d4a..0f58d5bf 100644 --- a/internal/app/bridge/bridge.go +++ b/internal/app/bridge/bridge.go @@ -40,10 +40,10 @@ import ( ) const ( - flagLogIMAP = "log-imap" - flagLogSMTP = "log-smtp" - flagNonInteractive = "noninteractive" - flagNonInteractiveShort = "n" + flagLogIMAP = "log-imap" + flagLogSMTP = "log-smtp" + flagNonInteractive = "noninteractive" + // Memory cache was estimated by empirical usage in the past, and it was set to 100MB. // NOTE: This value must not be less than maximal size of one email (~30MB). inMemoryCacheLimit = 100 * (1 << 20) @@ -62,9 +62,8 @@ func New(base *base.Base) *cli.App { Usage: "Enable logging of SMTP communications (may contain decrypted data!)", }, &cli.BoolFlag{ - Name: flagNonInteractive, - Aliases: []string{flagNonInteractiveShort}, - Usage: "Start Bridge entirely non-interactively", + Name: flagNonInteractive, + Usage: "Start Bridge entirely non-interactively", }, }...) @@ -73,11 +72,6 @@ func New(base *base.Base) *cli.App { func main(b *base.Base, c *cli.Context) error { //nolint:funlen frontendType := getFrontendTypeFromCLIParams(c) - if frontendType == frontend.Unknown { - _ = cli.ShowAppHelp(c) - return errors.New("no frontend was specified. Use --grpc, --cli or --noninteractive") - } - f := frontend.New( frontendType, !c.Bool(base.FlagNoWindow), @@ -177,14 +171,12 @@ func main(b *base.Base, c *cli.Context) error { //nolint:funlen func getFrontendTypeFromCLIParams(c *cli.Context) frontend.Type { switch { - case c.Bool(base.FlagGRPC): - return frontend.GRPC case c.Bool(base.FlagCLI): return frontend.CLI case c.Bool(flagNonInteractive): return frontend.NonInteractive default: - return frontend.Unknown + return frontend.GRPC } } diff --git a/internal/frontend/bridge-gui/bridge-gui/main.cpp b/internal/frontend/bridge-gui/bridge-gui/main.cpp index cca6e1cc..a7e787c4 100644 --- a/internal/frontend/bridge-gui/bridge-gui/main.cpp +++ b/internal/frontend/bridge-gui/bridge-gui/main.cpp @@ -257,7 +257,7 @@ void launchBridge(QStringList const &args) else app().log().debug(QString("Bridge executable path: %1").arg(QDir::toNativeSeparators(bridgeExePath))); - overseer = std::make_unique(new ProcessMonitor(bridgeExePath, QStringList("--grpc") + args, nullptr), nullptr); + overseer = std::make_unique(new ProcessMonitor(bridgeExePath, args, nullptr), nullptr); overseer->startWorker(true); } diff --git a/internal/frontend/frontend.go b/internal/frontend/frontend.go index de370e53..b701787f 100644 --- a/internal/frontend/frontend.go +++ b/internal/frontend/frontend.go @@ -25,7 +25,6 @@ import ( "github.com/ProtonMail/proton-bridge/v2/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/updater" "github.com/ProtonMail/proton-bridge/v2/pkg/listener" - "github.com/sirupsen/logrus" ) // Type describes the available types of frontend. @@ -35,7 +34,6 @@ const ( CLI Type = iota GRPC NonInteractive - Unknown ) type Frontend interface { @@ -47,7 +45,7 @@ type Frontend interface { WaitUntilFrontendIsReady() } -// New returns initialized frontend based on `frontendType`, which can be `CLI` or `GRPC`. Non-interactive will return a nil frontend. +// New returns initialized frontend based on `frontendType`, which can be `CLI` or `GRPC`. func New( frontendType Type, showWindowOnStart bool, @@ -77,13 +75,9 @@ func New( ) case NonInteractive: - return nil - - case Unknown: fallthrough default: - logrus.Panicf("Unexpected frontend value %v", frontendType) - return nil // return statement is required by compiler, although the above call will panic. + return nil } }