diff --git a/README.md b/README.md index 74ed7c4..9ef35dc 100755 --- a/README.md +++ b/README.md @@ -25,10 +25,13 @@ - **Cross-platform**. Supporting Windows, Mac OS X and Linux. - **Safe**. By ***checking potential conflicts and errors***. -- **File filtering**. Including and excluding files via regular expression. +- **File filtering**. Supporting including and excluding files via regular expression. No need to run commands like `find ./ -name "*.html" -exec CMD`. - **Recursively renaming both files and directories**. - **Supporting dry run**. +- **Colorful output**. Screenshots: + ![linux](screenshot/linux.png) + ![windows](screenshot/windows.png) ## Installation @@ -38,18 +41,18 @@ #### Method 1: Download binaries -[brename v2.1.1](https://github.com/shenwei356/brename/releases/tag/v2.1.1) -[![Github Releases (by Release)](https://img.shields.io/github/downloads/shenwei356/brename/v2.1.1/total.svg)](https://github.com/shenwei356/brename/releases/tag/v2.1.1) +[brename v2.1.2](https://github.com/shenwei356/brename/releases/tag/v2.1.2) +[![Github Releases (by Release)](https://img.shields.io/github/downloads/shenwei356/brename/v2.1.2/total.svg)](https://github.com/shenwei356/brename/releases/tag/v2.1.2) OS |Arch |File, (mirror为中国用户下载镜像链接) |Download Count :------|:---------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Linux |32-bit |[brename_linux_386.tar.gz](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_linux_386.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_linux_386.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_linux_386.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_linux_386.tar.gz) -Linux |**64-bit**|[**brename_linux_amd64.tar.gz**](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_linux_amd64.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_linux_amd64.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_linux_amd64.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_linux_amd64.tar.gz) -OS X |32-bit |[brename_darwin_386.tar.gz](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_darwin_386.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_darwin_386.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_darwin_386.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_darwin_386.tar.gz) -OS X |**64-bit**|[**brename_darwin_amd64.tar.gz**](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_darwin_amd64.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_darwin_amd64.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_darwin_amd64.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_darwin_amd64.tar.gz) -Windows|32-bit |[brename_windows_386.exe.tar.gz](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_windows_386.exe.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_windows_386.exe.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_windows_386.exe.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_windows_386.exe.tar.gz) -Windows|**64-bit**|[**brename_windows_amd64.exe.tar.gz**](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_windows_amd64.exe.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_windows_amd64.exe.tar.gz))|[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_windows_amd64.exe.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.1/brename_windows_amd64.exe.tar.gz) +Linux |32-bit |[brename_linux_386.tar.gz](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_linux_386.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_linux_386.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_linux_386.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_linux_386.tar.gz) +Linux |**64-bit**|[**brename_linux_amd64.tar.gz**](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_linux_amd64.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_linux_amd64.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_linux_amd64.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_linux_amd64.tar.gz) +OS X |32-bit |[brename_darwin_386.tar.gz](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_darwin_386.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_darwin_386.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_darwin_386.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_darwin_386.tar.gz) +OS X |**64-bit**|[**brename_darwin_amd64.tar.gz**](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_darwin_amd64.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_darwin_amd64.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_darwin_amd64.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_darwin_amd64.tar.gz) +Windows|32-bit |[brename_windows_386.exe.tar.gz](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_windows_386.exe.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_windows_386.exe.tar.gz)) |[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_windows_386.exe.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_windows_386.exe.tar.gz) +Windows|**64-bit**|[**brename_windows_amd64.exe.tar.gz**](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_windows_amd64.exe.tar.gz), ([mirror](http://app.shenwei.me/data/brename/brename_windows_amd64.exe.tar.gz))|[![Github Releases (by Asset)](https://img.shields.io/github/downloads/shenwei356/brename/latest/brename_windows_amd64.exe.tar.gz.svg?maxAge=3600)](https://github.com/shenwei356/brename/releases/download/v2.1.2/brename_windows_amd64.exe.tar.gz) Just [download](https://github.com/shenwei356/brename/releases) compressed @@ -81,7 +84,7 @@ And then: ``` brename -- a cross-platform command-line tool for safely batch renaming files/directories via regular expression -Version: 2.1.1 +Version: 2.1.2 Author: Wei Shen diff --git a/brename.go b/brename.go index 6d4f035..6e66291 100644 --- a/brename.go +++ b/brename.go @@ -33,13 +33,13 @@ import ( "github.com/fatih/color" "github.com/mattn/go-colorable" - "github.com/op/go-logging" + "github.com/shenwei356/go-logging" "github.com/spf13/cobra" ) var log *logging.Logger -var version = "2.1.1" +var version = "2.1.2" var app = "brename" // Options is the struct containing all global options @@ -134,7 +134,7 @@ func getOptions(cmd *cobra.Command) *Options { func init() { logFormat := logging.MustStringFormatter(`%{color}[%{level:.4s}]%{color:reset} %{message}`) var stderr io.Writer = os.Stderr - if isWindows { + if runtime.GOOS == "windows" { stderr = colorable.NewColorableStderr() } backend := logging.NewLogBackend(stderr, "", 0) @@ -397,8 +397,6 @@ var yellow = color.New(color.FgYellow).SprintFunc() var red = color.New(color.FgRed).SprintFunc() var green = color.New(color.FgGreen).SprintFunc() -var isWindows = runtime.GOOS == "windows" - func (c code) String() string { switch c { case codeOK: diff --git a/screenshot/linux.png b/screenshot/linux.png new file mode 100644 index 0000000..cdd862f Binary files /dev/null and b/screenshot/linux.png differ diff --git a/screenshot/windows.png b/screenshot/windows.png new file mode 100644 index 0000000..04ba3b2 Binary files /dev/null and b/screenshot/windows.png differ