Skip to content

Commit

Permalink
docs: 新增配置godis说明,修改帮助文档首字母为大写
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuacai168 committed Mar 16, 2021
1 parent 812b716 commit 3b883c2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# godis
# 什么是godis
- 使用`golang`实现的`redis cli`,二进制文件直接运行,无需任何依赖
- 支持安全模式,限制只能运行只读命令
- 支持常用`cluster``alone`模式的常用命令

# godis加入环境变量
- 下载release中对应平台的压缩包
- 解压,得到godis可执行文件
-`godis`可执行文件移动到`/usr/local/bin/`目录中(适用于Mac和Linux)
- `Windows`需要把`godis`所在的路径加入到系统的环境变量中

配置好之后,在命令行终端输入`godis`就能直接使用啦~
```
$ godis
A utility redis command line
Expand All @@ -11,19 +19,19 @@ Usage:
Available Commands:
config Handle godis configuration
del delete a key
exists assure a key is exists
hcopy copy a hash key
hdel hash key hget
del Delete a key
exists Assure a key is exists
hcopy Copy a hash key
hdel Hash key hdel
help Help about any command
hget hash key hget
hgetall hash key hgetall
hmset add a hash key, auto unpack jsonValue
renamenx rename key, if new_key is exist return fail, else success
sadd add a set key
smembers get set key values
ttl get key ttl
type get key type
hget Hash key hget
hgetall Hash key hgetall
hmset Add a hash key, auto unpack jsonValue
renamenx Rename key, if new_key is exist return fail, else success
sadd Add a set key
smembers Get set key values
ttl Get key ttl
type Get key type
```


Expand Down
10 changes: 5 additions & 5 deletions cmd/godis/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var hGetAllCmdShort = hGetAllCmd
var hGetAllCmd = &cobra.Command{
Use: "hgetall [key]",
Aliases: []string{"hga"},
Short: "hash key hgetall",
Short: "Hash key hgetall",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
result := hGetAll(args[0])
Expand All @@ -70,7 +70,7 @@ var hGetCmdShort = hGetCmd
var hGetCmd = &cobra.Command{
Use: "hget [key] [field]",
Aliases: []string{"hg"},
Short: "hash key hget",
Short: "Hash key hget",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
result := hGet(args[0], args[1])
Expand All @@ -83,7 +83,7 @@ var hDelCmdShort = hDelCmd
var hDelCmd = &cobra.Command{
Use: "hdel [key] [field]",
Aliases: []string{"hd"},
Short: "hash key hget",
Short: "Hash key hdel",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
if !isExists(args[0]) {
Expand All @@ -98,7 +98,7 @@ var hashCopyCmdShort = hashCopyCmd
var hashCopyCmd = &cobra.Command{
Use: "hcopy [old_key] [new_key]",
Aliases: []string{"hcp"},
Short: "copy a hash key",
Short: "Copy a hash key",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
result := hGetAll(args[0])
Expand All @@ -120,7 +120,7 @@ var hmsetCmdShort = hmsetCmd
var hmsetCmd = &cobra.Command{
Use: "hmset [key] [jsonValue]",
Aliases: []string{"hms"},
Short: "add a hash key, auto unpack jsonValue",
Short: "Add a hash key, auto unpack jsonValue",
Args: cobra.ExactArgs(2),
Example: `godis hash hmset test_key '{"a":1, "b": "b"}'`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
10 changes: 5 additions & 5 deletions cmd/godis/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
var deleteCmd = &cobra.Command{
Use: "del [key]",
Aliases: []string{"rm", "delete"},
Short: "delete a key",
Short: "Delete a key",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if !isExists(args[0]) {
Expand All @@ -45,7 +45,7 @@ var deleteCmd = &cobra.Command{

var existsCmd = &cobra.Command{
Use: "exists [key]",
Short: "assure a key is exists",
Short: "Assure a key is exists",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if isExists(args[0]) {
Expand All @@ -69,7 +69,7 @@ var keysCmd = &cobra.Command{

var typeCmd = &cobra.Command{
Use: "type [key]",
Short: "get key type",
Short: "Get key type",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
res := typeKey(args[0])
Expand All @@ -78,7 +78,7 @@ var typeCmd = &cobra.Command{
}
var ttlCmd = &cobra.Command{
Use: "ttl [key]",
Short: "get key ttl",
Short: "Get key ttl",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
res := ttlKey(args[0])
Expand All @@ -88,7 +88,7 @@ var ttlCmd = &cobra.Command{
var renamenxCmd = &cobra.Command{
Use: "renamenx [old_key] [new_key]",
Aliases: []string{"mv"},
Short: "rename key, if new_key is exist return fail, else success",
Short: "Rename key, if new_key is exist return fail, else success",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
//修改成功时,返回 1 。 如果 NEW_KEY_NAME 已经存在,返回 0 。
Expand Down
4 changes: 2 additions & 2 deletions cmd/godis/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var SMembersCmdShort = SMembersCmd
var SMembersCmd = &cobra.Command{
Use: "smembers [key]",
Aliases: []string{"sget"},
Short: "get set key values",
Short: "Get set key values",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
result := SMembers(args[0])
Expand Down Expand Up @@ -84,7 +84,7 @@ func SMembers(key string) []byte {
var SAddCmdShort = SAddCmd
var SAddCmd = &cobra.Command{
Use: "sadd [key] member1 member2 member3...",
Short: "add a set key",
Short: "Add a set key",
Args: cobra.RangeArgs(2, int(^uint(0)>>1)),
Run: func(cmd *cobra.Command, args []string) {
members := make([]interface{}, len(args))
Expand Down

0 comments on commit 3b883c2

Please sign in to comment.