mirror of
https://github.com/kemko/xc.git
synced 2026-01-01 15:55:43 +03:00
proper passmgr init
This commit is contained in:
11
cli/cli.go
11
cli/cli.go
@@ -129,13 +129,13 @@ func New(cfg *config.XCConfig, backend store.Backend) (*Cli, error) {
|
||||
cli.usePasswordMgr = true
|
||||
}
|
||||
}
|
||||
|
||||
remote.Initialize(cli.sshThreads, cli.user)
|
||||
remote.SetPrependHostnames(cli.prependHostnames)
|
||||
remote.SetRemoteTmpdir(cfg.RemoteTmpdir)
|
||||
remote.SetProgressBar(cli.progressBar)
|
||||
remote.SetConnectTimeout(cli.connectTimeout)
|
||||
remote.SetDebug(cli.debug)
|
||||
remote.SetUsePasswordManager(cli.usePasswordMgr)
|
||||
|
||||
// interpreter
|
||||
cli.setInterpreter("none", cfg.Interpreter)
|
||||
@@ -185,7 +185,7 @@ func (c *Cli) setPrompt() {
|
||||
}
|
||||
|
||||
if rts != "" {
|
||||
if c.raisePasswd == "" {
|
||||
if c.raisePasswd == "" && !c.usePasswordMgr {
|
||||
rts += "*"
|
||||
rtbold = true
|
||||
}
|
||||
@@ -431,14 +431,14 @@ func (c *Cli) dorunscript(mode execMode, argsLine string) {
|
||||
r.Print()
|
||||
}
|
||||
|
||||
func doOnOff(propName string, propRef *bool, args []string) {
|
||||
func doOnOff(propName string, propRef *bool, args []string) bool {
|
||||
if len(args) < 1 {
|
||||
value := "off"
|
||||
if *propRef {
|
||||
value = "on"
|
||||
}
|
||||
term.Warnf("%s is %s\n", propName, value)
|
||||
return
|
||||
return false
|
||||
}
|
||||
switch args[0] {
|
||||
case "on":
|
||||
@@ -447,8 +447,9 @@ func doOnOff(propName string, propRef *bool, args []string) {
|
||||
*propRef = false
|
||||
default:
|
||||
term.Errorf("Invalid %s vaue. Please use either \"on\" or \"off\"\n", propName)
|
||||
return
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Cli) setRaiseType(rt string) {
|
||||
|
||||
@@ -276,27 +276,31 @@ func (c *Cli) doDelay(name string, argsLine string, args ...string) {
|
||||
}
|
||||
|
||||
func (c *Cli) doDebug(name string, argsLine string, args ...string) {
|
||||
doOnOff("debug", &c.debug, args)
|
||||
remote.SetDebug(c.debug)
|
||||
if doOnOff("debug", &c.debug, args) {
|
||||
remote.SetDebug(c.debug)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cli) doProgressBar(name string, argsLine string, args ...string) {
|
||||
doOnOff("progressbar", &c.progressBar, args)
|
||||
remote.SetProgressBar(c.progressBar)
|
||||
if doOnOff("progressbar", &c.progressBar, args) {
|
||||
remote.SetProgressBar(c.progressBar)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cli) doPrependHostnames(name string, argsLine string, args ...string) {
|
||||
doOnOff("prepend_hostnames", &c.prependHostnames, args)
|
||||
remote.SetPrependHostnames(c.prependHostnames)
|
||||
if doOnOff("prepend_hostnames", &c.prependHostnames, args) {
|
||||
remote.SetPrependHostnames(c.prependHostnames)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cli) doUsePasswordManager(name string, argsLine string, args ...string) {
|
||||
doOnOff("use_password_manager", &c.usePasswordMgr, args)
|
||||
if c.usePasswordMgr && !passmgr.Ready() {
|
||||
term.Errorf("Password manager is not ready\n")
|
||||
c.usePasswordMgr = false
|
||||
if doOnOff("use_password_manager", &c.usePasswordMgr, args) {
|
||||
if c.usePasswordMgr && !passmgr.Ready() {
|
||||
term.Errorf("Password manager is not ready\n")
|
||||
c.usePasswordMgr = false
|
||||
}
|
||||
remote.SetUsePasswordManager(c.usePasswordMgr)
|
||||
}
|
||||
remote.SetUsePasswordManager(c.usePasswordMgr)
|
||||
}
|
||||
|
||||
func (c *Cli) doReload(name string, argsLine string, args ...string) {
|
||||
|
||||
Reference in New Issue
Block a user