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
a89e487a
Commit
a89e487a
authored
7 years ago
by
Michael Davis
Browse files
Options
Downloads
Patches
Plain Diff
[cta_frontend] Allows specification of optional options
parent
71f2957e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmdline/CtaAdminCmdParse.hpp
+40
-8
40 additions, 8 deletions
cmdline/CtaAdminCmdParse.hpp
with
40 additions
and
8 deletions
cmdline/CtaAdminCmdParse.hpp
+
40
−
8
View file @
a89e487a
...
...
@@ -182,6 +182,16 @@ struct Option
std
::
string
help_txt
;
bool
optional
;
/*!
* Constructor
*/
Option
(
option_t
otype
,
const
std
::
string
&
olong
,
const
std
::
string
&
oshort
,
const
std
::
string
&
ohelp
)
:
type
(
otype
),
long_opt
(
olong
),
short_opt
(
oshort
),
help_txt
(
ohelp
),
optional
(
false
)
{}
/*!
* Per-option help
*/
...
...
@@ -189,7 +199,7 @@ struct Option
{
std
::
string
help
=
" "
;
help
+=
optional
?
"["
:
""
;
help
+=
long_opt
+
'
'
+
short_opt
+
help_txt
;
help
+=
long_opt
+
'
/
'
+
short_opt
+
help_txt
;
help
+=
optional
?
"]"
:
""
;
return
help
;
}
...
...
@@ -298,9 +308,21 @@ const std::map<AdminCmd::Cmd, CmdHelp> cmdHelp = {
/*
* Enumerate options
*/
const
Option
opt_header
=
{
Option
::
OPT_FLAG
,
"--header"
,
"-h"
,
""
,
true
};
const
Option
opt_comment
=
{
Option
::
OPT_STR
,
"--comment"
,
"-m"
,
" <
\"
comment
\"
>"
,
false
};
const
Option
opt_hostname
=
{
Option
::
OPT_STR
,
"--hostname"
,
"-n"
,
" <host_name>"
,
false
};
const
Option
opt_comment
{
Option
::
OPT_STR
,
"--comment"
,
"-m"
,
" <
\"
comment
\"
>"
};
const
Option
opt_encrypted
{
Option
::
OPT_BOOL
,
"--encrypted"
,
"-e"
,
" <
\"
true
\"
or
\"
false
\"
>"
};
const
Option
opt_header
{
Option
::
OPT_FLAG
,
"--header"
,
"-h"
,
""
};
const
Option
opt_hostname
{
Option
::
OPT_STR
,
"--hostname"
,
"-n"
,
" <host_name>"
};
const
Option
opt_partialfiles
{
Option
::
OPT_INT
,
"--partial"
,
"-p"
,
" <number_of_files_per_tape>"
};
const
Option
opt_partialtapes
{
Option
::
OPT_INT
,
"--partialtapesnumber"
,
"-p"
,
" <number_of_partial_tapes>"
};
const
Option
opt_tapepool
{
Option
::
OPT_STR
,
"--tapepool"
,
"-n"
,
" <tapepool_name>"
};
const
Option
opt_username
{
Option
::
OPT_STR
,
"--username"
,
"-u"
,
" <user_name>"
};
/*!
* Make an option optional
*/
inline
Option
optional
(
Option
opt
)
{
opt
.
optional
=
true
;
return
opt
;
}
...
...
@@ -308,10 +330,20 @@ const Option opt_hostname = { Option::OPT_STR, "--hostname", "-n", " <host_name
* Map valid options to commands
*/
const
std
::
map
<
cmd_key_t
,
cmd_val_t
>
cmdOptions
=
{
{
{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_ADD
},
{
opt_hostname
,
opt_comment
}},
{
{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_CH
},
{
opt_hostname
,
opt_comment
}},
{
{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_RM
},
{
opt_hostname
}},
{
{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_LS
},
{
opt_header
}},
{{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_ADD
},
{
opt_username
,
opt_comment
}},
{{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_CH
},
{
opt_username
,
opt_comment
}},
{{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_RM
},
{
opt_username
}},
{{
AdminCmd
::
CMD_ADMIN
,
AdminCmd
::
SUBCMD_LS
},
{
optional
(
opt_header
)
}},
{{
AdminCmd
::
CMD_ADMINHOST
,
AdminCmd
::
SUBCMD_ADD
},
{
opt_hostname
,
opt_comment
}},
{{
AdminCmd
::
CMD_ADMINHOST
,
AdminCmd
::
SUBCMD_CH
},
{
opt_hostname
,
opt_comment
}},
{{
AdminCmd
::
CMD_ADMINHOST
,
AdminCmd
::
SUBCMD_RM
},
{
opt_hostname
}},
{{
AdminCmd
::
CMD_ADMINHOST
,
AdminCmd
::
SUBCMD_LS
},
{
optional
(
opt_header
)
}},
{{
AdminCmd
::
CMD_TAPEPOOL
,
AdminCmd
::
SUBCMD_ADD
},
{
opt_tapepool
,
opt_partialtapes
,
opt_encrypted
,
opt_comment
}},
{{
AdminCmd
::
CMD_TAPEPOOL
,
AdminCmd
::
SUBCMD_CH
},
{
opt_tapepool
,
optional
(
opt_partialtapes
),
optional
(
opt_encrypted
),
optional
(
opt_comment
)
}},
{{
AdminCmd
::
CMD_TAPEPOOL
,
AdminCmd
::
SUBCMD_RM
},
{
opt_tapepool
}},
{{
AdminCmd
::
CMD_TAPEPOOL
,
AdminCmd
::
SUBCMD_LS
},
{
optional
(
opt_header
)
}},
};
}}
// namespace cta::admin
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