cli

package
v0.0.0-...-69190e3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2017 License: Apache-2.0 Imports: 86 Imported by: 0

Documentation

Overview

Example (Basic)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug kv put basic1 1 basic2 2 basic3 3")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug kv del basic1 basic3")
c.Run("debug kv get basic1")
c.Run("debug kv get basic2")
c.Run("debug kv inc basic3 1")
c.Run("debug kv inc basic3 10")
c.Run("debug kv inc basic3 100")
c.Run("debug kv inc basic3 -- -60")
c.Run("debug kv inc basic3 -- -9")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug kv inc basic3 b")
Output:

debug kv put basic1 1 basic2 2 basic3 3
debug kv scan
"basic1"	"1"
"basic2"	"2"
"basic3"	"3"
3 result(s)
debug kv revscan
"basic3"	"3"
"basic2"	"2"
"basic1"	"1"
3 result(s)
debug kv del basic1 basic3
debug kv get basic1
"basic1" not found
debug kv get basic2
"2"
debug kv inc basic3 1
1
debug kv inc basic3 10
11
debug kv inc basic3 100
111
debug kv inc basic3 -- -60
51
debug kv inc basic3 -- -9
42
debug kv scan
"basic2"	"2"
"basic3"	42
2 result(s)
debug kv revscan
"basic3"	42
"basic2"	"2"
2 result(s)
debug kv inc basic3 b
invalid increment: strconv.ParseInt: parsing "b": invalid syntax
Example (Cput)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug kv put cput1 1 cput2 2 cput3 3 cput4 4")
c.Run("debug kv scan")
c.Run("debug kv cput cput5 5")
c.Run("debug kv cput cput2 3 2")
c.Run("debug kv scan")
Output:

debug kv put cput1 1 cput2 2 cput3 3 cput4 4
debug kv scan
"cput1"	"1"
"cput2"	"2"
"cput3"	"3"
"cput4"	"4"
4 result(s)
debug kv cput cput5 5
debug kv cput cput2 3 2
debug kv scan
"cput1"	"1"
"cput2"	"3"
"cput3"	"3"
"cput4"	"4"
"cput5"	"5"
5 result(s)
Example (Insecure)
c := newCLITest(cliTestParams{insecure: true})
defer c.cleanup()

c.Run("debug kv put insecure1 1 insecure2 2")
c.Run("debug kv scan")
Output:

debug kv put insecure1 1 insecure2 2
debug kv scan
"insecure1"	"1"
"insecure2"	"2"
2 result(s)
Example (Logging)
c := newCLITest(cliTestParams{})
defer c.cleanup()

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
Example (Max_results)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug kv put max_results1 1 max_results2 2 max_results3 3 max_results4 4")
c.Run("debug kv scan --max-results=3")
c.Run("debug kv revscan --max-results=2")
c.Run("debug range split max_results3")
c.Run("debug range split max_results4")
c.Run("debug range ls --max-results=2")
Output:

debug kv put max_results1 1 max_results2 2 max_results3 3 max_results4 4
debug kv scan --max-results=3
"max_results1"	"1"
"max_results2"	"2"
"max_results3"	"3"
3 result(s)
debug kv revscan --max-results=2
"max_results4"	"4"
"max_results3"	"3"
2 result(s)
debug range split max_results3
debug range split max_results4
debug range ls --max-results=2
/Min-"max_results3" [1]
	0: node-id=1 store-id=1
"max_results3"-"max_results4" [8]
	0: node-id=1 store-id=1
2 result(s)
Example (Node)
c := newCLITest(cliTestParams{})
defer c.cleanup()

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

c.Run("node ls")
c.Run("node ls --format=pretty")
c.Run("node status 10000")
Output:

node ls
1 row
id
1
node ls --format=pretty
+----+
| id |
+----+
|  1 |
+----+
(1 row)
node status 10000
Error: node 10000 doesn't exist
Example (Quoted)
c := newCLITest(cliTestParams{})
defer c.cleanup()

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

debug kv put quoted\x00 日本語
debug kv put quoted\x01 \u65e5\u672c\u8a9e
debug kv put quoted\x02 \U000065e5\U0000672c\U00008a9e
debug kv put quoted\x03 \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e
debug kv scan
"quoted\x00"	"日本語"
"quoted\x01"	"日本語"
"quoted\x02"	"日本語"
"quoted\x03"	"日本語"
4 result(s)
debug kv get quoted\x00
"日本語"
debug kv del quoted\x00
debug kv inc quoted\x04
1
debug kv get quoted\x04
1
Example (Ranges)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug kv put ranges1 1 ranges2 2 ranges3 3 ranges4 4")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug range split ranges3")
c.Run("debug range ls")
c.Run("debug kv scan")
c.Run("debug kv revscan")
c.Run("debug kv delrange ranges1 ranges3")
c.Run("debug kv scan")
Output:

debug kv put ranges1 1 ranges2 2 ranges3 3 ranges4 4
debug kv scan
"ranges1"	"1"
"ranges2"	"2"
"ranges3"	"3"
"ranges4"	"4"
4 result(s)
debug kv revscan
"ranges4"	"4"
"ranges3"	"3"
"ranges2"	"2"
"ranges1"	"1"
4 result(s)
debug range split ranges3
debug range ls
/Min-"ranges3" [1]
	0: node-id=1 store-id=1
"ranges3"-/Table/0 [8]
	0: node-id=1 store-id=1
/Table/0-/Table/11 [2]
	0: node-id=1 store-id=1
/Table/11-/Table/12 [3]
	0: node-id=1 store-id=1
/Table/12-/Table/13 [4]
	0: node-id=1 store-id=1
/Table/13-/Table/14 [5]
	0: node-id=1 store-id=1
/Table/14-/Table/15 [6]
	0: node-id=1 store-id=1
/Table/15-/Max [7]
	0: node-id=1 store-id=1
8 result(s)
debug kv scan
"ranges1"	"1"
"ranges2"	"2"
"ranges3"	"3"
"ranges4"	"4"
4 result(s)
debug kv revscan
"ranges4"	"4"
"ranges3"	"3"
"ranges2"	"2"
"ranges1"	"1"
4 result(s)
debug kv delrange ranges1 ranges3
debug kv scan
"ranges3"	"3"
"ranges4"	"4"
2 result(s)
Example (Sql)
c := newCLITest(cliTestParams{})
defer c.cleanup()

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", "select 1; select 2"})
c.RunWithArgs([]string{"sql", "-e", "select 1; select 2 where false"})
// It must be possible to access pre-defined/virtual tables even if the current database
// does not exist yet.
c.RunWithArgs([]string{"sql", "-d", "nonexistent", "-e", "select count(*) from pg_class limit 0"})
// It must be possible to create the current database after the
// connection was established.
c.RunWithArgs([]string{"sql", "-d", "nonexistent", "-e", "create database nonexistent; create table foo(x int); select * from foo"})
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
5 rows
Database
crdb_internal
information_schema
pg_catalog
system
t
sql -e select 1; select 2
1 row
1
1
1 row
2
2
sql -e select 1; select 2 where false
1 row
1
1
0 rows
2
sql -d nonexistent -e select count(*) from pg_class limit 0
0 rows
count(*)
sql -d nonexistent -e create database nonexistent; create table foo(x int); select * from foo
0 rows
x
Example (Sql_column_labels)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.u (\"\"\"foo\" int, \"\\foo\" int, \"foo\nbar\" int, \"κόσμε\" int, \"a|b\" int, \"܈85\" int)"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.u values (0, 0, 0, 0, 0, 0)"})
c.RunWithArgs([]string{"sql", "-e", "show columns from t.u"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "show columns from t.u"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=tsv", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=csv", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=sql", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=html", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=records", "-e", "select * from t.u"})
Output:

sql -e create database t; create table t.u ("""foo" int, "\foo" int, "foo
bar" int, "κόσμε" int, "a|b" int, "܈85" int)
CREATE TABLE
sql -e insert into t.u values (0, 0, 0, 0, 0, 0)
INSERT 1
sql -e show columns from t.u
6 rows
Field	Type	Null	Default	Indices
"""foo"	INT	true	NULL	{}
\foo	INT	true	NULL	{}
"foo
bar"	INT	true	NULL	{}
κόσμε	INT	true	NULL	{}
a|b	INT	true	NULL	{}
܈85	INT	true	NULL	{}
sql -e select * from t.u
1 row
"""foo"	\foo	"""foo\nbar"""	κόσμε	a|b	܈85
0	0	0	0	0	0
sql --format=pretty -e show columns from t.u
+---------+------+------+---------+---------+
|  Field  | Type | Null | Default | Indices |
+---------+------+------+---------+---------+
| "foo    | INT  | true | NULL    | {}      |
| \foo    | INT  | true | NULL    | {}      |
| foo␤    | INT  | true | NULL    | {}      |
| bar     |      |      |         |         |
| κόσμε   | INT  | true | NULL    | {}      |
| a|b     | INT  | true | NULL    | {}      |
| ܈85     | INT  | true | NULL    | {}      |
+---------+------+------+---------+---------+
(6 rows)
sql --format=pretty -e select * from t.u
+------+------+------------+-------+-----+-----+
| "foo | \foo | "foo\nbar" | κόσμε | a|b | ܈85 |
+------+------+------------+-------+-----+-----+
|    0 |    0 |          0 |     0 |   0 |   0 |
+------+------+------------+-------+-----+-----+
(1 row)
sql --format=tsv -e select * from t.u
1 row
"""foo"	\foo	"""foo\nbar"""	κόσμε	a|b	܈85
0	0	0	0	0	0
sql --format=csv -e select * from t.u
1 row
"""foo",\foo,"""foo\nbar""",κόσμε,a|b,܈85
0,0,0,0,0,0
sql --format=sql -e select * from t.u
CREATE TABLE results (
  """foo" STRING,
  "\foo" STRING,
  """foo\nbar""" STRING,
  κόσμε STRING,
  "a|b" STRING,
  ܈85 STRING
);

INSERT INTO results VALUES ('0', '0', '0', '0', '0', '0');
sql --format=html -e select * from t.u
<table>
<thead><tr><th>&#34;foo</th><th>\foo</th><th>&#34;foo\nbar&#34;</th><th>κόσμε</th><th>a|b</th><th>܈85</th></tr></head>
<tbody>
<tr><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>
</tbody>
</table>
sql --format=records -e select * from t.u
-[ RECORD 1 ]
"foo       | 0
\foo       | 0
"foo\nbar" | 0
κόσμε      | 0
a|b        | 0
܈85        | 0
Example (Sql_format)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.times (bare timestamp, withtz timestamptz)"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.times values ('2016-01-25 10:10:10', '2016-01-25 10:10:10-05:00')"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.times"})
Output:

sql -e create database t; create table t.times (bare timestamp, withtz timestamptz)
CREATE TABLE
sql -e insert into t.times values ('2016-01-25 10:10:10', '2016-01-25 10:10:10-05:00')
INSERT 1
sql -e select * from t.times
1 row
bare	withtz
2016-01-25 10:10:10+00:00	2016-01-25 15:10:10+00:00
Example (Sql_table)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.t (s string, d string);"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'foo', 'printable ASCII')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\"foo', 'printable ASCII with quotes')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\\\foo', 'printable ASCII with backslash')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'foo\\x0abar', 'non-printable ASCII')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values ('κόσμε', 'printable UTF8')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\xc3\\xb1', 'printable UTF8 using escapes')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\x01', 'non-printable UTF8 string')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\xdc\\x88\\x38\\x35', 'UTF8 string with RTL char')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\xc3\\x28', 'non-UTF8 string')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'a\\tb\\tc\\n12\\t123123213\\t12313', 'tabs')"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=tsv", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=csv", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=sql", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=html", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=records", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "select '  hai' as x"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "explain(indent) select s from t.t union all select s from t.t"})
Output:

sql -e create database t; create table t.t (s string, d string);
CREATE TABLE
sql -e insert into t.t values (e'foo', 'printable ASCII')
INSERT 1
sql -e insert into t.t values (e'"foo', 'printable ASCII with quotes')
INSERT 1
sql -e insert into t.t values (e'\\foo', 'printable ASCII with backslash')
INSERT 1
sql -e insert into t.t values (e'foo\x0abar', 'non-printable ASCII')
INSERT 1
sql -e insert into t.t values ('κόσμε', 'printable UTF8')
INSERT 1
sql -e insert into t.t values (e'\xc3\xb1', 'printable UTF8 using escapes')
INSERT 1
sql -e insert into t.t values (e'\x01', 'non-printable UTF8 string')
INSERT 1
sql -e insert into t.t values (e'\xdc\x88\x38\x35', 'UTF8 string with RTL char')
INSERT 1
sql -e insert into t.t values (e'\xc3\x28', 'non-UTF8 string')
pq: invalid UTF-8 byte sequence
insert into t.t values (e'\xc3\x28', 'non-UTF8 string')
                        ^

sql -e insert into t.t values (e'a\tb\tc\n12\t123123213\t12313', 'tabs')
INSERT 1
sql -e select * from t.t
9 rows
s	d
foo	printable ASCII
"""foo"	printable ASCII with quotes
\foo	printable ASCII with backslash
"foo
bar"	non-printable ASCII
κόσμε	printable UTF8
ñ	printable UTF8 using escapes
"""\x01"""	non-printable UTF8 string
܈85	UTF8 string with RTL char
"a	b	c
12	123123213	12313"	tabs
sql --format=pretty -e select * from t.t
+--------------------------------+--------------------------------+
|               s                |               d                |
+--------------------------------+--------------------------------+
| foo                            | printable ASCII                |
| "foo                           | printable ASCII with quotes    |
| \foo                           | printable ASCII with backslash |
| foo␤                           | non-printable ASCII            |
| bar                            |                                |
| κόσμε                          | printable UTF8                 |
| ñ                              | printable UTF8 using escapes   |
| "\x01"                         | non-printable UTF8 string      |
| ܈85                            | UTF8 string with RTL char      |
| a   b         c␤               | tabs                           |
| 12  123123213 12313            |                                |
+--------------------------------+--------------------------------+
(9 rows)
sql --format=tsv -e select * from t.t
9 rows
s	d
foo	printable ASCII
"""foo"	printable ASCII with quotes
\foo	printable ASCII with backslash
"foo
bar"	non-printable ASCII
κόσμε	printable UTF8
ñ	printable UTF8 using escapes
"""\x01"""	non-printable UTF8 string
܈85	UTF8 string with RTL char
"a	b	c
12	123123213	12313"	tabs
sql --format=csv -e select * from t.t
9 rows
s,d
foo,printable ASCII
"""foo",printable ASCII with quotes
\foo,printable ASCII with backslash
"foo
bar",non-printable ASCII
κόσμε,printable UTF8
ñ,printable UTF8 using escapes
"""\x01""",non-printable UTF8 string
܈85,UTF8 string with RTL char
"a	b	c
12	123123213	12313",tabs
sql --format=sql -e select * from t.t
CREATE TABLE results (
  s STRING,
  d STRING
);

INSERT INTO results VALUES ('foo', 'printable ASCII');
INSERT INTO results VALUES ('"foo', 'printable ASCII with quotes');
INSERT INTO results VALUES (e'\\foo', 'printable ASCII with backslash');
INSERT INTO results VALUES (e'foo\nbar', 'non-printable ASCII');
INSERT INTO results VALUES (e'\u03BA\U00001F79\u03C3\u03BC\u03B5', 'printable UTF8');
INSERT INTO results VALUES (e'\u00F1', 'printable UTF8 using escapes');
INSERT INTO results VALUES (e'"\\x01"', 'non-printable UTF8 string');
INSERT INTO results VALUES (e'\u070885', 'UTF8 string with RTL char');
INSERT INTO results VALUES (e'a\tb\tc\n12\t123123213\t12313', 'tabs');
sql --format=html -e select * from t.t
<table>
<thead><tr><th>s</th><th>d</th></tr></head>
<tbody>
<tr><td>foo</td><td>printable ASCII</td></tr>
<tr><td>&#34;foo</td><td>printable ASCII with quotes</td></tr>
<tr><td>\foo</td><td>printable ASCII with backslash</td></tr>
<tr><td>foo<br/>bar</td><td>non-printable ASCII</td></tr>
<tr><td>κόσμε</td><td>printable UTF8</td></tr>
<tr><td>ñ</td><td>printable UTF8 using escapes</td></tr>
<tr><td>&#34;\x01&#34;</td><td>non-printable UTF8 string</td></tr>
<tr><td>܈85</td><td>UTF8 string with RTL char</td></tr>
<tr><td>a	b	c<br/>12	123123213	12313</td><td>tabs</td></tr>
</tbody>
</table>
sql --format=records -e select * from t.t
-[ RECORD 1 ]
s | foo
d | printable ASCII
-[ RECORD 2 ]
s | "foo
d | printable ASCII with quotes
-[ RECORD 3 ]
s | \foo
d | printable ASCII with backslash
-[ RECORD 4 ]
s | foo
  | bar
d | non-printable ASCII
-[ RECORD 5 ]
s | κόσμε
d | printable UTF8
-[ RECORD 6 ]
s | ñ
d | printable UTF8 using escapes
-[ RECORD 7 ]
s | "\x01"
d | non-printable UTF8 string
-[ RECORD 8 ]
s | ܈85
d | UTF8 string with RTL char
-[ RECORD 9 ]
s | a	b	c
  | 12	123123213	12313
d | tabs
sql --format=pretty -e select '  hai' as x
+-------+
|   x   |
+-------+
|   hai |
+-------+
(1 row)
sql --format=pretty -e explain(indent) select s from t.t union all select s from t.t
+-------+--------+-------+--------------------+
| Level |  Type  | Field |    Description     |
+-------+--------+-------+--------------------+
|     0 | append |       |  -> append         |
|     1 | render |       |    -> render       |
|     2 | scan   |       |       -> scan      |
|     2 |        | table |          t@primary |
|     2 |        | spans |          ALL       |
|     1 | render |       |    -> render       |
|     2 | scan   |       |       -> scan      |
|     2 |        | table |          t@primary |
|     2 |        | spans |          ALL       |
+-------+--------+-------+--------------------+
(9 rows)
Example (User)
c := newCLITest(cliTestParams{})
defer c.cleanup()

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

user ls
0 rows
username
user ls --format=pretty
+----------+
| username |
+----------+
+----------+
(0 rows)
user ls --format=tsv
0 rows
username
user set foo
INSERT 1
user ls --format=pretty
+----------+
| username |
+----------+
| foo      |
+----------+
(1 row)
user rm foo
DELETE 1
user ls --format=pretty
+----------+
| username |
+----------+
+----------+
(0 rows)
Example (Zip)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug zip /dev/null")
Output:

debug zip /dev/null
writing /dev/null
  debug/events
  debug/liveness
  debug/nodes/1/status
  debug/nodes/1/gossip
  debug/nodes/1/stacks
  debug/nodes/1/ranges/1
  debug/nodes/1/ranges/2
  debug/nodes/1/ranges/3
  debug/nodes/1/ranges/4
  debug/nodes/1/ranges/5
  debug/nodes/1/ranges/6
  debug/nodes/1/ranges/7
  debug/schema/system@details
  debug/schema/system/descriptor
  debug/schema/system/eventlog
  debug/schema/system/jobs
  debug/schema/system/lease
  debug/schema/system/namespace
  debug/schema/system/rangelog
  debug/schema/system/ui
  debug/schema/system/users
  debug/schema/system/zones
Example (Zone)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("zone ls")
c.Run("zone set system --file=./testdata/zone_attrs.yaml")
c.Run("zone ls")
c.Run("zone get system.nonexistent")
c.Run("zone get system.lease")
c.Run("zone set system --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone get system")
c.Run("zone rm system")
c.Run("zone ls")
c.Run("zone rm .default")
c.Run("zone set .default --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone get system")
c.Run("zone set .default --disable-replication")
c.Run("zone get system")
Output:

zone ls
.default
zone set system --file=./testdata/zone_attrs.yaml
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: [us-east-1a, ssd]
zone ls
.default
system
zone get system.nonexistent
system.nonexistent not found
zone get system.lease
system
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: [us-east-1a, ssd]
zone set system --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: [us-east-1a, ssd]
zone get system
system
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: [us-east-1a, ssd]
zone rm system
DELETE 1
zone ls
.default
zone rm .default
unable to remove .default
zone set .default --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone get system
.default
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone set .default --disable-replication
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: []
zone get system
.default
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: []

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrorCode = 1

ErrorCode is the value to be used by main() as exit code in case of error. For most errors 1 is appropriate, but a signal termination can change this.

Functions

func InitCLIDefaults

func InitCLIDefaults()

InitCLIDefaults is used for testing.

func Main

func Main()

Main is the entry point for the cli, with a single line calling it intended to be the body of an action package main `main` func elsewhere. It is abstracted for reuse by duplicated `main` funcs in different distributions.

func MakeDBClient

func MakeDBClient() (*client.DB, *stop.Stopper, error)

MakeDBClient creates a kv client for use in cli tools.

func MaybeDecorateGRPCError

func MaybeDecorateGRPCError(
	wrapped func(*cobra.Command, []string) error,
) func(*cobra.Command, []string) error

MaybeDecorateGRPCError catches grpc errors and provides a more helpful error message to the user.

func Run

func Run(args []string) error

Run ...

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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