The ultimate CLI tool for TiKV

tcli

The ultimate CLI tool for TiKV

>>> help

Commands:
  .connect      connect to a tikv cluster, usage: [.connect|.conn|.c] [pd addr], example: .c 192.168.1.1:2379
  .stores       list tikv stores in cluster
  bench         bench [type] config1=value1 config2=value2 ...
                  type: ycsb
  clear         clear the screen
  echo          echo [string lit]
  exit          exit the program
  get           get [string lit]
  help          display help
  loadfile      loadfile [filename] [key prefix] [opts], only supports CSV now, when "key prefix" is set, will automatically add prefix to the original key,
                opts:
                  batch-size: int, how many records in one tikv transaction, default: 1000
  put           put [key] [value]
  scan          Scan key-value pairs in range, usage: scan [start key] [opts]
                  opt format: key1=value1,key2=value2,key3=value3,
                  scan options:
                    limit: integer, default:100
                    key-only: true(1)|false(0)
                    strict-prefix: true(1)|false(0)
                    count-only: true(1)|false(0)
     
Owner
dongxu
Infrastructure engineer / entrepreneur, CTO & Co-founder of PingCAP.
dongxu
Comments
  • Support flexible workflows and outputs

    Support flexible workflows and outputs

    I would like to propose some changes that help support more flexible workflows; namely, piping formatted key-value operation results to output files:

    • [x] Redirect non-result console output to Stderr so that Stdout only receives results of key-value operations
    • [ ] Implement options to configure formatting of key-value output (i.e., JSON, csv)
  • Enabled edit sysenv command

    Enabled edit sysenv command

    Enabled edit sysenv command to edit system environment variables. Current usage: sysvar [name]="[value]"

    image

    With these changes, it is now possible to change output format inside tcli.

  • redirect logging output to stderr

    redirect logging output to stderr

    Redirect logging output to stderr, as proposed in #11. Also configured ishell to exit immediately on EOF without printing an error to stdout (ishell runs into EOF when piping in commands via echo or printf).

    After these changes, only returned key-value pairs are output to Stdout.

  • Support to release via goreleaser

    Support to release via goreleaser

    See the test process:

    @LinuxSuRen ➜ /workspaces/tcli (release) $ goreleaser build --rm-dist --snapshot
      • starting build...
      • loading config file                              file=.goreleaser.yml
      • loading environment variables
      • getting and validating git state
        • couldn't find any tags before "v0.0.1"
        • building...                                    commit=bb1aa985113d164fb23014cdf9caa6f96b2fa1b9 latest tag=v0.0.1
        • pipe skipped                                   reason=disabled during snapshot mode
      • parsing tag
      • setting defaults
      • snapshotting
        • building snapshot...                           version=v0.0.1-next-bb1aa98
      • checking distribution directory
      • loading go mod information
      • build prerequisites
      • writing effective config file
        • writing                                        config=release/config.yaml
      • building binaries
        • building                                       binary=release/tcli_darwin_amd64_v1/tcli
        • building                                       binary=release/tcli_windows_amd64_v1/tcli.exe
        • building                                       binary=release/tcli_linux_amd64_v1/tcli
        • took: 1m23s
      • storing release metadata
        • writing                                        file=release/artifacts.json
        • writing                                        file=release/metadata.json
      • build succeeded after 1m23s
    @LinuxSuRen ➜ /workspaces/tcli (release) $ ./release/tcli_linux_amd64_v1/tcli -h
    Usage of ./release/tcli_linux_amd64_v1/tcli:
      -log-file string
            TiKV client log file (default "/dev/null")
      -log-level string
            TiKV client log level (default "info")
      -mode string
            TiKV API mode, accepted values: [raw | txn] (default "txn")
      -output-format string
            output format, accepted values: [table | json] (default "table")
      -pd string
            PD addr (default "localhost:2379")
    

    Attention

    Before merging this PR, please don't forget to add the following secret to this repository:

    • GH_PUBLISH_SECRETS is the GitHub personal token which has the permission to upload files into the release

    fix #22

  • fixed rawkv bug when searching for non-existent key

    fixed rawkv bug when searching for non-existent key

    rawKV returns nil value and nil error when attempting to retrieve a key that doesn't exist. tcli's rawKV client should now catch these cases and output errors accordingly.

  • Refactor and fix JSON output formatting

    Refactor and fix JSON output formatting

    Part of #11. Refactored output formatting in client/client.go. Also changed JSON output formatting to convert to strings before marshaling; previous implementation would directly marshal the array of KV structs, causing unexpected behavior when handling the byte array keys and values.

    Currently, there is no way to change output formatting inside tcli without rebuilding it. In order to test these changes, you can go to utils/variables.go and change the value of SysVarPrintFormatKey to json, and then build the application again.

    https://github.com/c4pt0r/tcli/blob/d6ed5b2077a0abe34f2f8a50b4abb6c22a2997d9/utils/variables.go#L23

    image

  • Rawkv

    Rawkv

    Implemented most functions in rawKV client. Currently, a few functions such as getPDClient and getStores cannot be implemented because the rawKV client does not export its pd client attribute.

    rawkv mode can be used by setting flag -mode=raw when running tcli

  • update module s.t. we can install with `go install ...`

    update module s.t. we can install with `go install ...`

    Otherwise

    $ go install github.com/c4pt0r/tcli@latest
    go: downloading github.com/c4pt0r/tcli v0.0.0-20211209143356-b0706808a1f0
    go install: github.com/c4pt0r/tcli@latest: github.com/c4pt0r/[email protected]: parsing go.mod:
    	module declares its path as: tcli
    	        but was required as: github.com/c4pt0r/tcli
    
  • Fix backup command

    Fix backup command

    Fixes #24 simply by changing the index on which the scans for flags would start. This was previously index 1 which contradicts the current help page and implemented logic, it was changed to 2.

  • backup command wrongly treats the output file argument as a parameter

    backup command wrongly treats the output file argument as a parameter

    When trying to create a backup from a local TiKV I get an error telling me that it got a wrong flag format. This error is generated consistently always and there is no way to actually use the command.

    Sample terminal output with redacted host name and cluster ID:

    ubuntu@server-42:~$ tcli
    Try connecting to PD: localhost:2379...done
    Welcome, TiKV Cluster ID: 1234567890123456789, TiKV Mode: Mode: Txn
    Mode: Txn @ http://server-42.private:2379> backup
    dumps kv pairs to a csv file
    Usage: 
            backup <prefix> <outfile> <opts>
    Options:
            --batch-size=<size>, default 1000
    Example:
            # backup all kvs with prefix "t_" to csv file
            backup "t_" backup.csv --batch-size=5000
    
            # backup all kvs to csv file
            backup * backup.csv
            backup $head  backup.csv
    
    Success
    Elapse: 0 ms
    Mode: Txn @ http://server-42.private:2379> backup preifx file.csv
    Error: wrong flag format: [file.csv] 
    Elapse: 0 ms
    Mode: Txn @ http://server-42.private:2379> backup preifx file.csv --batch-size=1024
    Error: wrong flag format: [file.csv] 
    Elapse: 0 ms
    Mode: Txn @ http://server-42.private:2379>  
    

    Using any of the proposed examples in the help/usage output yields the same error:

    Error: wrong flag format: [file.csv] 
    
  • Short-term milestones

    Short-term milestones

    Some short-term milestone of tcli:

    • [x] Basic KV commands support: get/set/delete/scan/count/...
    • [x] CSV import/restore
    • [x] Basic benchmark: ycsb
    • [x] Variable support
    • [ ] RawKV mode (WIP)
    • [ ] JSON value via json-path: jget/jput/jscan (WIP)
    • [ ] RESTFul API server
    • [ ] Cluster info/operation
    • [ ] Better commnad completetion
  • Can not get raw key putted by tikv golang client

    Can not get raw key putted by tikv golang client

    hi:

    I put rawkey use golang client , and my code is

    	cli, err := rawkv.NewClient(context.TODO(), []string{"xx.xx.xx.xx:2379"}, config.DefaultConfig().Security)
    	if err != nil {
    		panic(err)
    	}
    	defer cli.Close()
           	var prefix = "prefix"
    	for i := 0; i < 10; i++ {
    
    		key := []byte(prefix + strconv.Itoa(i))
    		val := []byte("PingCAP" + strconv.Itoa(i))
    		err = cli.Put(context.TODO(), key, val)
    		if err != nil {
    			panic(err)
    		}
    		fmt.Printf("Successfully put %s:%s to tikv\n", key, val)
    		val, err = cli.Get(context.TODO(), key)
    		if err != nil {
    			panic(err)
    		}
    		fmt.Printf("found val: %s for key: %s\n", val, key)
    	}
    
    

    I can get the key like "prefix0",but can not get from tcli

Related tags
Symfony-cli - The Symfony CLI tool For Golang

Symfony CLI Install To install Symfony CLI, please download the appropriate vers

Dec 28, 2022
bcrypt-cli is the CLI tool for hashing passwords with bcrypt.

bcrypt-cli bcrypt-cli is the CLI tool for hashing passwords with bcrypt. Install go install github.com/ryicoh/bcrypt-cli Usage It can be used like bas

Jan 9, 2023
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework

This is the official CLI tool to operate with Getting Things Done Framework. How

Feb 14, 2022
This tool is a CLI-interactive tool for TA who use eeclass platform

NTHU eeclass TA helper. This tool is a CLI-interactive tool for TA who use eeclass platform. It helps TA to download all the submitted homework, and use CSV to record the score and comment, and upload CSV score directly to the eeclass platform with just 2 Enter key!

Dec 11, 2021
Elegant CLI wrapper for kubeseal CLI

Overview This is a wrapper CLI ofkubeseal CLI, specifically the raw mode. If you just need to encrypt your secret on RAW mode, this CLI will be the ea

Jan 8, 2022
CLI to run a docker image with R. CLI built using cobra library in go.
CLI  to run a docker image with R. CLI built using cobra library in go.

BlueBeak Installation Guide Task 1: Building the CLI The directory structure looks like Fastest process: 1)cd into bbtools 2)cd into bbtools/bin 3)I h

Dec 20, 2021
A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode.

aliyun-dns A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode. Installation Install aliyun-cli. Usage $ aliyun-dns -h A wra

Dec 21, 2021
Go-file-downloader-ftctl - A file downloader cli built using golang. Makes use of cobra for building the cli and go concurrent feature to download files.

ftctl This is a file downloader cli written in Golang which uses the concurrent feature of go to download files. The cli is built using cobra. How to

Jan 2, 2022
Cli-algorithm - A cli program with A&DS in go!

cli-algorithm Objectives The objective of this cli is to implement 4 basic algorithms to sort arrays been Merge Sort Insertion Sort Bubble Sort Quick

Jan 2, 2022
Nebulant-cli - Nebulant's CLI
Nebulant-cli - Nebulant's CLI

Nebulant CLI Website: https://nebulant.io Documentation: https://nebulant.io/docs.html The Nebulant CLI tool is a single binary that can be used as a

Jan 11, 2022
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it

news-parser-cli Simple CLI which allows you to receive news depending on the par

Jan 4, 2022
Go-api-cli - Small CLI to fetch data from an API sync and async

Async API Cli CLI to fetch data on "todos" from a given API in a number of ways.

Jan 13, 2022
Syno-cli - Synology unofficial API CLI and library

Synology CLI Unofficial wrapper over Synology API in Go. Focus on administrative

Jan 6, 2023
Gobby-cli - CLI application to debug gobby applications

go(bby) Interactive debugging tool for gobby applications Usage Coming soon™ Ins

Feb 8, 2022
A CLI tool implemented by Golang to manage `CloudComb` resource

CloudComb CLI tool: comb Get Started comb is a CLI tool for manage resources in CloudComb base on cloudcomb-go-sdk. Support Mac, Linux and Windows. We

Jan 4, 2021
A small CLI tool to check connection from a local machine to a remote target in various protocols.

CHK chk is a small CLI tool to check connection from a local machine to a remote target in various protocols.

Oct 10, 2022
A CLI Tool to easily generate your Terraform configuration

Tf Tf is a command line tool to easily generate your Terraform configuration with an interactive prompt. Inspiration Boredom in Covid-19 Installation

Sep 30, 2022
A powerful cli tool to implement gin annotation ⭐
A powerful cli tool to implement gin annotation ⭐

gin-annotation A powerful cli tool to implement gin annotation Chinese Document Features Using code generating technology by operating golang AST Rout

Mar 24, 2022