Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
e3d70fdb
Commit
e3d70fdb
authored
3 years ago
by
Tigran Mkrtchyan
Browse files
Options
Downloads
Patches
Plain Diff
cta-dcache: add help and version to command line options
parent
a99d5e6d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cta-dcache/gRPC/FrontendGRpcSvc.cpp
+30
-2
30 additions, 2 deletions
cta-dcache/gRPC/FrontendGRpcSvc.cpp
with
30 additions
and
2 deletions
cta-dcache/gRPC/FrontendGRpcSvc.cpp
+
30
−
2
View file @
e3d70fdb
...
...
@@ -167,15 +167,37 @@ CtaRpcImpl::CtaRpcImpl(cta::log::LogContext *lc, std::unique_ptr<cta::catalogue:
using
namespace
cta
;
using
namespace
cta
::
common
;
std
::
string
help
=
"Usage: cta-dcache [options]
\n
"
"
\n
"
"where options can be:
\n
"
"
\n
"
"
\t
--port <port>, -p <port>:
\t
TCP port number to use, defaults to 17017
\n
"
"
\t
--log-header, -n
\t
add hostname and timestamp to log outputs
\n
"
"
\t
--no-log-header, -s
\t
don't add hostname and timestamp to log outputs, defalut
\n
"
"
\t
--version, -v
\t
print version and exit.
\n
"
"
\t
--help, -h
\t
print this help and exit
\n
"
;
static
struct
option
long_options
[]
=
{
{
"port"
,
required_argument
,
0
,
'p'
},
{
"log-header"
,
no_argument
,
0
,
'n'
},
{
"no-log-header"
,
no_argument
,
0
,
's'
},
{
"help"
,
no_argument
,
0
,
'h'
},
{
"version"
,
no_argument
,
0
,
'v'
},
{
0
,
0
,
0
,
0
}
};
void
printHelpAndExit
(
int
rc
)
{
std
::
cout
<<
help
<<
std
::
endl
;
exit
(
rc
);
}
void
printVersionAndExit
()
{
std
::
cout
<<
"cta-dcache version: "
<<
CTA_VERSION
<<
std
::
endl
;
exit
(
0
);
}
int
main
(
const
int
argc
,
char
*
const
*
const
argv
)
{
std
::
string
port
=
"17017"
;
...
...
@@ -185,7 +207,7 @@ int main(const int argc, char *const *const argv) {
int
option_index
=
0
;
const
std
::
string
shortHostName
=
utils
::
getShortHostname
();
while
(
(
c
=
getopt_long
(
argc
,
argv
,
"p:ns"
,
long_options
,
&
option_index
))
!=
EOF
)
{
while
(
(
c
=
getopt_long
(
argc
,
argv
,
"p:ns
hv
"
,
long_options
,
&
option_index
))
!=
EOF
)
{
switch
(
c
)
{
case
'p'
:
...
...
@@ -197,8 +219,14 @@ int main(const int argc, char *const *const argv) {
case
's'
:
shortHeader
=
false
;
break
;
case
'h'
:
printHelpAndExit
(
0
);
break
;
case
'v'
:
printVersionAndExit
();
break
;
default:
e
xit
(
1
);
printHelpAndE
xit
(
1
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment