mirror of
https://github.com/kemko/xc.git
synced 2026-01-01 15:55:43 +03:00
rcfile restored
This commit is contained in:
21
cli/cli.go
21
cli/cli.go
@@ -152,6 +152,8 @@ func New(cfg *config.XCConfig, backend store.Backend) (*Cli, error) {
|
||||
cli.doMode("mode", "mode", cfg.Mode)
|
||||
|
||||
cli.setPrompt()
|
||||
cli.runRC(cfg.RCfile)
|
||||
|
||||
return cli, nil
|
||||
}
|
||||
|
||||
@@ -487,3 +489,22 @@ func (c *Cli) setDistributeType(dtr string) {
|
||||
}
|
||||
remote.SetDistributeType(c.distributeType)
|
||||
}
|
||||
|
||||
func (c *Cli) runRC(rcfile string) {
|
||||
f, err := os.Open(rcfile)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
term.Errorf("Error loading rcfile: %s\n", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
term.Successf("Running rcfile %s...", rcfile)
|
||||
sc := bufio.NewScanner(f)
|
||||
for sc.Scan() {
|
||||
cmd := sc.Text()
|
||||
fmt.Println(term.Green(cmd))
|
||||
c.OneCmd(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/viert/xc/config"
|
||||
|
||||
"github.com/viert/xc/passmgr"
|
||||
"github.com/viert/xc/remote"
|
||||
"github.com/viert/xc/term"
|
||||
@@ -365,9 +367,10 @@ func (c *Cli) doOutput(name string, argsLine string, args ...string) {
|
||||
return
|
||||
}
|
||||
|
||||
err := c.setOutput(argsLine)
|
||||
outputFilename := config.ExpandPath(argsLine)
|
||||
err := c.setOutput(outputFilename)
|
||||
if err == nil {
|
||||
c.outputFileName = argsLine
|
||||
c.outputFileName = outputFilename
|
||||
term.Successf("Output is copied to %s\n", c.outputFileName)
|
||||
} else {
|
||||
term.Errorf("Error setting output file to %s: %s\n", argsLine, err)
|
||||
|
||||
Reference in New Issue
Block a user