-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. install.sh 3. build info
- Loading branch information
liujianping
committed
Jun 26, 2019
1 parent
b1fb616
commit f079d47
Showing
584 changed files
with
293,776 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
dist/* | ||
bin/ | ||
dist/ | ||
.vscode/ |
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 |
---|---|---|
@@ -1,15 +1,31 @@ | ||
ts | ||
=== | ||
timestamp convert & compare tool | ||
[![GoDoc](https://godoc.org/github.com/liujianping/ts?status.svg)](https://godoc.org/github.com/liujianping/ts) [![Go Report Card](https://goreportcard.com/badge/github.com/liujianping/ts)](https://goreportcard.com/report/github.com/liujianping/ts) [![Build Status](https://travis-ci.org/liujianping/ts.svg?branch=master)](https://travis-ci.org/liujianping/ts) [![Version](https://img.shields.io/github/tag/liujianping/ts.svg)](https://github.com/liujianping/ts/releases) [![Coverage Status](https://coveralls.io/repos/github/liujianping/ts/badge.svg?branch=master)](https://coveralls.io/github/liujianping/ts?branch=master) | ||
|
||
## Install | ||
|
||
### Shell Install support Linux & MacOS | ||
|
||
````bash | ||
$: brew tap liujianping/tap && brew install ts | ||
# binary will be $(go env GOPATH)/bin/ts | ||
$: curl -sfL https://raw.githubusercontent.com/liujianping/ts/master/install.sh | sh -s -- -b $(go env GOPATH)/bin | ||
|
||
# In alpine linux (as it does not come with curl by default) | ||
$: wget -O - -q https://raw.githubusercontent.com/liujianping/ts/master/install.sh | sh -s | ||
|
||
```` | ||
|
||
//OR | ||
### Brew Install only MacOS | ||
````bash | ||
$: brew tap liujianping/tap && brew install ts | ||
```` | ||
|
||
$: go get github.com/liujianping/ts | ||
### Source Install | ||
````bash | ||
$: git clone [email protected]:liujianping/ts.git | ||
$: cd ts | ||
$: go install -mod vendor | ||
```` | ||
|
||
## Quick Start | ||
|
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,110 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/x-mod/errors" | ||
) | ||
|
||
func TestVersion(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
cmd.Flags().Set("version", "true") | ||
assert.Nil(t, Main(cmd, []string{})) | ||
} | ||
|
||
func TestArgs(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
assert.Nil(t, Main(cmd, []string{})) | ||
} | ||
|
||
func TestTimezone(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
cmd.Flags().Set("timezone", "asdfasdf") | ||
assert.NotNil(t, Main(cmd, []string{})) | ||
|
||
cmd.Flags().Set("timezone", "Asia/Shanghai") | ||
assert.Nil(t, Main(cmd, []string{})) | ||
} | ||
|
||
func TestAddSub(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
cmd.Flags().Set("add", "1h") | ||
assert.Nil(t, Main(cmd, []string{})) | ||
cmd.Flags().Set("sub", "1h") | ||
assert.Nil(t, Main(cmd, []string{})) | ||
} | ||
|
||
func TestBefore(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
cmd.Flags().Set("before", "2039adfasdf") | ||
assert.NotNil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("before", "2039/12/12") | ||
e1 := Main(cmd, []string{"2019/06/12"}) | ||
assert.NotNil(t, e1) | ||
assert.Equal(t, int32(1), errors.ValueFrom(e1), e1.Error()) | ||
assert.Nil(t, Main(cmd, []string{"2040/06/12"})) | ||
} | ||
|
||
func TestAfter(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
cmd.Flags().Set("after", "2009fasdfa") | ||
assert.NotNil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("after", "2009/01/01") | ||
e2 := Main(cmd, []string{"2019/06/12"}) | ||
assert.NotNil(t, e2) | ||
assert.Equal(t, int32(1), errors.ValueFrom(e2), e2.Error()) | ||
assert.Nil(t, Main(cmd, []string{"2008/06/12"})) | ||
} | ||
|
||
func TestFormat(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
cmd.Flags().Set("format", "2039sadfadsfa") | ||
assert.NotNil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "2039/12/12") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "ANSIC") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "UnixDate") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RubyDate") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC822") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC822Z") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC850") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC1123") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC1123Z") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC3339") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "RFC3339Nano") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "Kitchen") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "Stamp") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "StampMilli") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "StampMicro") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
cmd.Flags().Set("format", "StampNano") | ||
assert.Nil(t, Main(cmd, []string{"2019/06/12"})) | ||
} | ||
|
||
func TestCovert(t *testing.T) { | ||
cmd := RootCmd() | ||
viper.BindPFlags(cmd.Flags()) | ||
assert.NotNil(t, Main(cmd, []string{"2019asdfafd"})) | ||
} |
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.