cmd

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright © 2021 lihuacai

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ConnectSuccess = "PONG"
)
View Source
var SAddCmd = &cobra.Command{
	Use:   "sadd [key] member1 member2 member3...",
	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))
		for index, arg := range args {
			if index == 0 {
				continue
			}
			members[index] = arg
		}
		SAdd(args[0], members[1:])
		result := SMembers(args[0])
		fmt.Println("sadd success, set key is "+args[0], ", value is ")
		_, _ = colorableOut.Write(result)
		fmt.Fprintln(outWriter)
	},
}
View Source
var SAddCmdShort = SAddCmd
View Source
var SMembersCmd = &cobra.Command{
	Use:     "smembers [key]",
	Aliases: []string{"sget"},
	Short:   "Get set key values",
	Args:    cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		result := SMembers(args[0])
		_, _ = colorableOut.Write(result)
		fmt.Fprintln(outWriter)
	},
}
View Source
var SMembersCmdShort = SMembersCmd

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func JsonToMap

func JsonToMap(jsonStr string) (map[string]interface{}, error)

Convert json string to map

func SAdd added in v1.0.0

func SAdd(key string, members []interface{})

func SMembers

func SMembers(key string) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL