-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 新增目录文件同步子命令fsync - 简化README.md描述内容,详细使用说明,迁移到wiki中 - 命令提示中增加Example提示,交互更友好 - 优化原有功能的实现方式,如#6;使用format.Source格式化go代码;
- Loading branch information
Showing
19 changed files
with
504 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/yesAnd92/lwe/handler/sync" | ||
) | ||
|
||
var ( | ||
dryrRun bool | ||
|
||
fsyncCmd = &cobra.Command{ | ||
Use: `fsync`, | ||
Short: `Sync file from source dir to target dir`, | ||
Long: `Sync file from source dir to target dir,and it will skip existing files`, | ||
Example: `lwe fsync sourceDir targetDir [-d=true]`, | ||
Args: cobra.MatchAll(cobra.ExactArgs(2)), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
sourceDir := args[0] | ||
targetDir := args[1] | ||
|
||
var thenDo sync.CompareThenDoIfa = &sync.CopyCompareThenDo{} | ||
if dryrRun { | ||
thenDo = &sync.DisplayCompareThenDo{} | ||
} | ||
fsync := sync.InitFsync(sourceDir, targetDir) | ||
|
||
//compare source and target dir diff | ||
fsync.DiffDir() | ||
|
||
fsync.Sync(thenDo) | ||
}, | ||
} | ||
) | ||
|
||
func init() { | ||
|
||
//dry-run | ||
fsyncCmd.PersistentFlags().BoolVarP(&dryrRun, "dry-run", "d", false, "Because fsync can make some significant changes, you might prefer to add --dry-run=true option"+ | ||
" to the command line to preview what fsync plans to do") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.