Skip to content

Commit

Permalink
fix(v1.0): support 实时输出
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Apr 6, 2020
1 parent 1a78e7e commit 0a6c8c2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 151 deletions.
7 changes: 3 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ var rootCmd = &cobra.Command{

func exec(ssh *sshutil.SSH, mode, host string) {
switch mode {
case "ssh":
ssh.Cmd(host, command)
case "scp":
ssh.CopyForMD5(host, localFilePath, remoteFilePath, "")
case "sshAsync":
case "ssh":
_ = ssh.CmdAsync(host, command)
}
}
Expand Down Expand Up @@ -113,6 +111,7 @@ func Execute() {
}

func init() {
logger.Cfg()
// Here you will define your flags and configuration settings.
rootCmd.Flags().StringVar(&user, "user", "root", "servers user name for ssh")
rootCmd.Flags().StringVar(&password, "passwd", "", "password for ssh")
Expand All @@ -121,5 +120,5 @@ func init() {
rootCmd.Flags().StringVar(&command, "cmd", "", "exec shell")
rootCmd.Flags().StringVar(&localFilePath, "local-path", "", "local path , ex /etc/local.txt")
rootCmd.Flags().StringVar(&remoteFilePath, "remote-path", "", "local path , ex /etc/local.txt")
rootCmd.Flags().StringVar(&mode, "mode", "ssh", "mode type ,use | spilt . ex ssh sshAsync scp ssh|scp scp|ssh")
rootCmd.Flags().StringVar(&mode, "mode", "ssh", "mode type ,use | spilt . ex ssh scp ssh|scp scp|ssh")
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ require (
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
)

replace github.com/wonderivan/logger => github.com/fanux/sealos/pkg/logger v0.0.0-20200406033522-73f3ef41977c
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fanux/sealos/pkg/logger v0.0.0-20200406033522-73f3ef41977c h1:oegX8xgoZ4xCXK7o2D8tLQd4uyQ8EVhsozRKOc+z5bI=
github.com/fanux/sealos/pkg/logger v0.0.0-20200406033522-73f3ef41977c/go.mod h1:x9AaKiPmaa1lNJIu5XXJs1En2wZayGN6UA3dgYozYFk=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
Expand Down Expand Up @@ -37,8 +39,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/wonderivan/logger v1.0.0 h1:Z6Nz+3SNcizolx3ARH11axdD4DXjFpb2J+ziGUVlv/U=
github.com/wonderivan/logger v1.0.0/go.mod h1:NObMfQ3WOLKfYEZuGeZQfuQfSPE5+QNgRddVMzsAT/k=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
58 changes: 0 additions & 58 deletions pkg/cmd/watch.go

This file was deleted.

27 changes: 0 additions & 27 deletions pkg/filesize/filesize.go

This file was deleted.

2 changes: 2 additions & 0 deletions pkg/sshutil/scp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"time"
)

const oneMBByte = 1024 * 1024

//Copy is
func (ss *SSH) CopyForMD5(host, localFilePath, remoteFilePath, md5 string) bool {
//如果有md5则可以验证
Expand Down
60 changes: 0 additions & 60 deletions pkg/sshutil/watch.go

This file was deleted.

0 comments on commit 0a6c8c2

Please sign in to comment.