You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.9 KiB
94 lines
2.9 KiB
// Copyright (c) 2021 Proton Technologies AG |
|
// |
|
// This file is part of ProtonMail Bridge. |
|
// |
|
// ProtonMail Bridge is free software: you can redistribute it and/or modify |
|
// it under the terms of the GNU General Public License as published by |
|
// the Free Software Foundation, either version 3 of the License, or |
|
// (at your option) any later version. |
|
// |
|
// ProtonMail Bridge 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 General Public License for more details. |
|
// |
|
// You should have received a copy of the GNU General Public License |
|
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>. |
|
|
|
package cli |
|
|
|
import ( |
|
"github.com/abiosoft/ishell" |
|
"github.com/ljanyst/peroxide/pkg/config/settings" |
|
"github.com/ljanyst/peroxide/pkg/updater" |
|
) |
|
|
|
func (f *frontendCLI) checkUpdates(c *ishell.Context) { |
|
version, err := f.updater.Check() |
|
if err != nil { |
|
f.Println("An error occurred while checking for updates.") |
|
return |
|
} |
|
|
|
if f.updater.IsUpdateApplicable(version) { |
|
f.Println("An update is available.") |
|
} else { |
|
f.Println("Your version is up to date.") |
|
} |
|
} |
|
|
|
func (f *frontendCLI) printCredits(c *ishell.Context) { |
|
} |
|
|
|
func (f *frontendCLI) enableAutoUpdates(c *ishell.Context) { |
|
if f.settings.GetBool(settings.AutoUpdateKey) { |
|
f.Println("Bridge is already set to automatically install updates.") |
|
return |
|
} |
|
|
|
f.Println("Bridge is currently set to NOT automatically install updates.") |
|
|
|
if f.yesNoQuestion("Are you sure you want to allow bridge to do this") { |
|
f.settings.SetBool(settings.AutoUpdateKey, true) |
|
} |
|
} |
|
|
|
func (f *frontendCLI) disableAutoUpdates(c *ishell.Context) { |
|
if !f.settings.GetBool(settings.AutoUpdateKey) { |
|
f.Println("Bridge is already set to NOT automatically install updates.") |
|
return |
|
} |
|
|
|
f.Println("Bridge is currently set to automatically install updates.") |
|
|
|
if f.yesNoQuestion("Are you sure you want to stop bridge from doing this") { |
|
f.settings.SetBool(settings.AutoUpdateKey, false) |
|
} |
|
} |
|
|
|
func (f *frontendCLI) selectEarlyChannel(c *ishell.Context) { |
|
if f.bridge.GetUpdateChannel() == updater.EarlyChannel { |
|
f.Println("Bridge is already on the early-access update channel.") |
|
return |
|
} |
|
|
|
f.Println("Bridge is currently on the stable update channel.") |
|
|
|
if f.yesNoQuestion("Are you sure you want to switch to the early-access update channel") { |
|
f.bridge.SetUpdateChannel(updater.EarlyChannel) |
|
} |
|
} |
|
|
|
func (f *frontendCLI) selectStableChannel(c *ishell.Context) { |
|
if f.bridge.GetUpdateChannel() == updater.StableChannel { |
|
f.Println("Bridge is already on the stable update channel.") |
|
return |
|
} |
|
|
|
f.Println("Bridge is currently on the early-access update channel.") |
|
f.Println("Switching to the stable channel may reset all data!") |
|
|
|
if f.yesNoQuestion("Are you sure you want to switch to the stable update channel") { |
|
f.bridge.SetUpdateChannel(updater.StableChannel) |
|
} |
|
}
|
|
|