Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
a2d6a81f
Incubator Pegasus
项目概览
apache
/
Incubator Pegasus
通知
9
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Incubator Pegasus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a2d6a81f
编写于
10月 28, 2018
作者:
W
Wu Tao
提交者:
QinZuoyan
10月 28, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shell: implement cc command (#196)
上级
417c6266
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
19 deletion
+39
-19
src/shell/commands.h
src/shell/commands.h
+14
-0
src/shell/main.cpp
src/shell/main.cpp
+25
-19
未找到文件。
src/shell/commands.h
浏览文件 @
a2d6a81f
...
...
@@ -544,6 +544,20 @@ inline bool use_app_as_current(command_executor *e, shell_context *sc, arguments
}
}
extern
void
check_in_cluster
(
std
::
string
cluster_name
);
inline
bool
cc_command
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
if
(
args
.
argc
==
2
)
{
std
::
string
cluster_name
=
args
.
argv
[
1
];
if
(
!
cluster_name
.
empty
())
{
check_in_cluster
(
cluster_name
);
return
true
;
}
}
return
false
;
}
inline
bool
process_escape_all
(
command_executor
*
e
,
shell_context
*
sc
,
arguments
args
)
{
if
(
args
.
argc
==
1
)
{
...
...
src/shell/main.cpp
浏览文件 @
a2d6a81f
...
...
@@ -101,6 +101,9 @@ static command_executor commands[] = {
"[app_name]"
,
use_app_as_current
,
},
{
"cc"
,
"check in the specified cluster"
,
"[cluster_name]"
,
cc_command
,
},
{
"escape_all"
,
"if escape all characters when printing key/value bytes"
,
...
...
@@ -507,22 +510,8 @@ static char *hintsCallback(const char *buf, int *color, int *bold)
/* Linenoise free hints callback. */
static
void
freeHintsCallback
(
void
*
ptr
)
{
sdsfree
((
sds
)
ptr
);
}
void
initialize
(
int
argc
,
char
**
argv
)
/*extern*/
void
check_in_cluster
(
std
::
string
cluster_name
)
{
std
::
cout
<<
"Pegasus Shell "
<<
PEGASUS_VERSION
<<
std
::
endl
;
std
::
cout
<<
"Type
\"
help
\"
for more information."
<<
std
::
endl
;
std
::
cout
<<
"Type
\"
Ctrl-D
\"
or
\"
Ctrl-C
\"
to exit the shell."
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
std
::
string
config_file
=
argc
>
1
?
argv
[
1
]
:
"config.ini"
;
if
(
!
pegasus
::
pegasus_client_factory
::
initialize
(
config_file
.
c_str
()))
{
std
::
cout
<<
"ERROR: init pegasus failed: "
<<
config_file
<<
std
::
endl
;
dsn_exit
(
-
1
);
}
else
{
std
::
cout
<<
"The config file is: "
<<
config_file
<<
std
::
endl
;
}
std
::
string
cluster_name
=
argc
>
2
?
argv
[
2
]
:
"mycluster"
;
s_global_context
.
current_cluster_name
=
cluster_name
;
std
::
string
section
=
"uri-resolver.dsn://"
+
s_global_context
.
current_cluster_name
;
std
::
string
key
=
"arguments"
;
...
...
@@ -530,8 +519,8 @@ void initialize(int argc, char **argv)
dsn
::
replication
::
replica_helper
::
load_meta_servers
(
s_global_context
.
meta_list
,
section
.
c_str
(),
key
.
c_str
());
s_global_context
.
ddl_client
.
reset
(
new
dsn
::
replication
::
replication_ddl_client
(
s_global_context
.
meta_list
)
);
s_global_context
.
ddl_client
=
dsn
::
make_unique
<
dsn
::
replication
::
replication_ddl_client
>
(
s_global_context
.
meta_list
);
// get real cluster name from zk
std
::
string
name
;
...
...
@@ -541,6 +530,25 @@ void initialize(int argc, char **argv)
}
std
::
cout
<<
"The cluster name is: "
<<
cluster_name
<<
std
::
endl
;
std
::
cout
<<
"The cluster meta list is: "
<<
server_list
<<
std
::
endl
;
}
void
initialize
(
int
argc
,
char
**
argv
)
{
std
::
cout
<<
"Pegasus Shell "
<<
PEGASUS_VERSION
<<
std
::
endl
;
std
::
cout
<<
"Type
\"
help
\"
for more information."
<<
std
::
endl
;
std
::
cout
<<
"Type
\"
Ctrl-D
\"
or
\"
Ctrl-C
\"
to exit the shell."
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
std
::
string
config_file
=
argc
>
1
?
argv
[
1
]
:
"config.ini"
;
if
(
!
pegasus
::
pegasus_client_factory
::
initialize
(
config_file
.
c_str
()))
{
std
::
cout
<<
"ERROR: init pegasus failed: "
<<
config_file
<<
std
::
endl
;
dsn_exit
(
-
1
);
}
else
{
std
::
cout
<<
"The config file is: "
<<
config_file
<<
std
::
endl
;
}
std
::
string
cluster_name
=
argc
>
2
?
argv
[
2
]
:
"mycluster"
;
check_in_cluster
(
cluster_name
);
linenoiseSetMultiLine
(
1
);
linenoiseSetCompletionCallback
(
completionCallback
);
...
...
@@ -586,7 +594,6 @@ int main(int argc, char **argv)
return
0
;
}
#if defined(__linux__)
#include <dsn/git_commit.h>
#include <dsn/version.h>
#include <pegasus/git_commit.h>
...
...
@@ -603,4 +610,3 @@ static char const rcsid[] =
#endif
", built at "
__DATE__
" "
__TIME__
" $"
;
const
char
*
pegasus_shell_rcsid
()
{
return
rcsid
;
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录