cockroach: github.com/abhinavdahiya/cockroach/cli Index | Examples | Files | Directories

package cli

import "github.com/abhinavdahiya/cockroach/cli"

Code:

c := newCLITest()
defer c.stop()

c.Run("debug kv put a 1 b 2 c 3")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug kv del a c")
c.Run("debug kv get a")
c.Run("debug kv get b")
c.Run("debug kv inc c 1")
c.Run("debug kv inc c 10")
c.Run("debug kv inc c 100")
c.Run("debug kv inc c -- -60")
c.Run("debug kv inc c -- -9")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug kv inc c b")

Output:

debug kv put a 1 b 2 c 3
debug kv scan
"a"	"1"
"b"	"2"
"c"	"3"
3 result(s)
debug kv revscan
"c"	"3"
"b"	"2"
"a"	"1"
3 result(s)
debug kv del a c
debug kv get a
"a" not found
debug kv get b
"2"
debug kv inc c 1
1
debug kv inc c 10
11
debug kv inc c 100
111
debug kv inc c -- -60
51
debug kv inc c -- -9
42
debug kv scan
"b"	"2"
"c"	42
2 result(s)
debug kv revscan
"c"	42
"b"	"2"
2 result(s)
debug kv inc c b
invalid increment: b: strconv.ParseInt: parsing "b": invalid syntax

Code:

c := newCLITest()
defer c.stop()

c.Run("debug kv put a 1 b 2 c 3 d 4")
c.Run("debug kv scan")
c.Run("debug kv cput e 5")
c.Run("debug kv cput b 3 2")
c.Run("debug kv scan")

Output:

debug kv put a 1 b 2 c 3 d 4
debug kv scan
"a"	"1"
"b"	"2"
"c"	"3"
"d"	"4"
4 result(s)
debug kv cput e 5
debug kv cput b 3 2
debug kv scan
"a"	"1"
"b"	"3"
"c"	"3"
"d"	"4"
"e"	"5"
5 result(s)

Code:

s, err := serverutils.StartServerRaw(
    base.TestServerArgs{Insecure: true})
if err != nil {
    log.Fatalf("Could not start server: %v", err)
}
defer s.Stopper().Stop()
c := cliTest{TestServer: s.(*server.TestServer), cleanupFunc: func() {}}

c.Run("debug kv put --insecure a 1 b 2")
c.Run("debug kv scan --insecure")

Output:

debug kv put --insecure a 1 b 2
debug kv scan --insecure
"a"	"1"
"b"	"2"
2 result(s)

Code:

c := newCLITest()
defer c.stop()

c.RunWithArgs([]string{"sql", "--alsologtostderr=false", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--log-backtrace-at=foo.go:1", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--log-dir=", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--logtostderr=true", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--verbosity=0", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--vmodule=foo=1", "-e", "select 1"})

Output:

sql --alsologtostderr=false -e select 1
1 row
1
1
sql --log-backtrace-at=foo.go:1 -e select 1
1 row
1
1
sql --log-dir= -e select 1
1 row
1
1
sql --logtostderr=true -e select 1
1 row
1
1
sql --verbosity=0 -e select 1
1 row
1
1
sql --vmodule=foo=1 -e select 1
1 row
1
1

Code:

c := newCLITest()
defer c.stop()

// Refresh time series data, which is required to retrieve stats.
if err := c.TestServer.WriteSummaries(); err != nil {
    log.Fatalf("Couldn't write stats summaries: %s", err)
}

c.Run("node ls")
c.Run("node ls --pretty")
c.Run("node status 10000")

Output:

node ls
1 row
id
1
node ls --pretty
+----+
| id |
+----+
|  1 |
+----+
(1 row)
node status 10000
Error: node 10000 doesn't exist

Code:

c := newCLITest()
defer c.stop()

c.Run(`debug kv put a\x00 日本語`)                                  // UTF-8 input text
c.Run(`debug kv put a\x01 \u65e5\u672c\u8a9e`)                   // explicit Unicode code points
c.Run(`debug kv put a\x02 \U000065e5\U0000672c\U00008a9e`)       // explicit Unicode code points
c.Run(`debug kv put a\x03 \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e`) // explicit UTF-8 bytes
c.Run(`debug kv scan`)
c.Run(`debug kv get a\x00`)
c.Run(`debug kv del a\x00`)
c.Run(`debug kv inc 1\x01`)
c.Run(`debug kv get 1\x01`)

Output:

debug kv put a\x00 日本語
debug kv put a\x01 \u65e5\u672c\u8a9e
debug kv put a\x02 \U000065e5\U0000672c\U00008a9e
debug kv put a\x03 \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e
debug kv scan
"a\x00"	"日本語"
"a\x01"	"日本語"
"a\x02"	"日本語"
"a\x03"	"日本語"
4 result(s)
debug kv get a\x00
"日本語"
debug kv del a\x00
debug kv inc 1\x01
1
debug kv get 1\x01
1

Code:

c := newCLITest()
defer c.stop()

c.Run("debug kv put a 1 b 2 c 3 d 4")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug range split c")
c.Run("debug range ls")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug kv delrange a c")
c.Run("debug kv scan")

Output:

debug kv put a 1 b 2 c 3 d 4
debug kv scan
"a"	"1"
"b"	"2"
"c"	"3"
"d"	"4"
4 result(s)
debug kv revscan
"d"	"4"
"c"	"3"
"b"	"2"
"a"	"1"
4 result(s)
debug range split c
debug range ls
/Min-"c" [1]
	0: node-id=1 store-id=1
"c"-/Table/11 [6]
	0: node-id=1 store-id=1
/Table/11-/Table/12 [2]
	0: node-id=1 store-id=1
/Table/12-/Table/13 [3]
	0: node-id=1 store-id=1
/Table/13-/Table/14 [4]
	0: node-id=1 store-id=1
/Table/14-/Max [5]
	0: node-id=1 store-id=1
6 result(s)
debug kv scan
"a"	"1"
"b"	"2"
"c"	"3"
"d"	"4"
4 result(s)
debug kv revscan
"d"	"4"
"c"	"3"
"b"	"2"
"a"	"1"
4 result(s)
debug kv delrange a c
debug kv scan
"c"	"3"
"d"	"4"
2 result(s)

Code:

c := newCLITest()
defer c.stop()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.f (x int, y int); insert into t.f values (42, 69)"})
c.RunWithArgs([]string{"sql", "-e", "select 3", "-e", "select * from t.f"})
c.RunWithArgs([]string{"sql", "-e", "begin", "-e", "select 3", "-e", "commit"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.f"})
c.RunWithArgs([]string{"sql", "--execute=show databases"})
c.RunWithArgs([]string{"sql", "-e", "explain select 3"})
c.RunWithArgs([]string{"sql", "-e", "select 1; select 2"})

Output:

sql -e create database t; create table t.f (x int, y int); insert into t.f values (42, 69)
INSERT 1
sql -e select 3 -e select * from t.f
1 row
3
3
1 row
x	y
42	69
sql -e begin -e select 3 -e commit
BEGIN
1 row
3
3
COMMIT
sql -e select * from t.f
1 row
x	y
42	69
sql --execute=show databases
2 rows
Database
system
t
sql -e explain select 3
1 row
Level	Type	Description
0	empty	-
sql -e select 1; select 2
1 row
1
1
1 row
2
2

Code:

c := newCLITest()
defer c.stop()

c.Run("user ls")
c.Run("user ls --pretty")
c.Run("user ls --pretty=false")
c.Run("user set foo --password=bar")
// Don't use get, since the output of hashedPassword is random.
// c.Run("user get foo")
c.Run("user ls --pretty")
c.Run("user rm foo")
c.Run("user ls --pretty")

Output:

user ls
0 rows
username
user ls --pretty
+----------+
| username |
+----------+
+----------+
(0 rows)
user ls --pretty=false
0 rows
username
user set foo --password=bar
INSERT 1
user ls --pretty
+----------+
| username |
+----------+
| foo      |
+----------+
(1 row)
user rm foo
DELETE 1
user ls --pretty
+----------+
| username |
+----------+
+----------+
(0 rows)

Code:

c := newCLITest()
defer c.stop()

const zone1 = `replicas:
- attrs: [us-east-1a,ssd]`
const zone2 = `range_max_bytes: 134217728`

c.Run("zone ls")
// Call RunWithArgs to bypass the "split-by-whitespace" arg builder.
c.RunWithArgs([]string{"zone", "set", "system", zone1})
c.Run("zone ls")
c.Run("zone get system.nonexistent")
c.Run("zone get system.lease")
c.RunWithArgs([]string{"zone", "set", "system", zone2})
c.Run("zone get system")
c.Run("zone rm system")
c.Run("zone ls")
c.Run("zone rm .default")
c.RunWithArgs([]string{"zone", "set", ".default", zone2})
c.Run("zone get system")

Output:

zone ls
.default
zone set system replicas:
- attrs: [us-east-1a,ssd]
INSERT 1
replicas:
- attrs: [us-east-1a, ssd]
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
zone ls
.default
system
zone get system.nonexistent
system.nonexistent not found
zone get system.lease
system
replicas:
- attrs: [us-east-1a, ssd]
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
zone set system range_max_bytes: 134217728
UPDATE 1
replicas:
- attrs: [us-east-1a, ssd]
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
zone get system
system
replicas:
- attrs: [us-east-1a, ssd]
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
zone rm system
DELETE 1
zone ls
.default
zone rm .default
unable to remove .default
zone set .default range_max_bytes: 134217728
UPDATE 1
replicas:
- attrs: []
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
zone get system
.default
replicas:
- attrs: []
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400

Index

Examples

Package Files

backtrace.go cert.go cli.go context.go debug.go dump.go flags.go gen.go keytype_string.go kv.go node.go range.go sql.go sql_util.go start.go start_jemalloc.go user.go zone.go

func Run Uses

func Run(args []string) error

Run ...

Directories

PathSynopsis
cliflags

Package cli imports 71 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).