Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
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
Maunium
synapse
Commits
fdefb9e2
Commit
fdefb9e2
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Move creation of ArgumentParser to caller
parent
37b524f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/app/admin_cmd.py
+3
-1
3 additions, 1 deletion
synapse/app/admin_cmd.py
synapse/config/_base.py
+5
-10
5 additions, 10 deletions
synapse/config/_base.py
with
8 additions
and
11 deletions
synapse/app/admin_cmd.py
+
3
−
1
View file @
fdefb9e2
...
...
@@ -13,6 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
logging
import
sys
...
...
@@ -105,7 +106,8 @@ def export_data_command(hs, user_id, directory):
def
start
(
config_options
):
parser
=
HomeServerConfig
.
create_argument_parser
(
"
Synapse Admin Command
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
Synapse Admin Command
"
)
HomeServerConfig
.
add_arguments_to_parser
(
parser
)
subparser
=
parser
.
add_subparsers
(
title
=
"
Admin Commands
"
,
...
...
This diff is collapsed.
Click to expand it.
synapse/config/_base.py
+
5
−
10
View file @
fdefb9e2
...
...
@@ -231,27 +231,24 @@ class Config(object):
Returns: Config object.
"""
config_parser
=
cls
.
create_argument_parser
(
description
)
config_parser
=
argparse
.
ArgumentParser
(
description
=
description
)
cls
.
add_arguments_to_parser
(
config_parser
)
obj
,
_
=
cls
.
load_config_with_parser
(
config_parser
,
argv
)
return
obj
@classmethod
def
create
_argument_parser
(
cls
,
description
):
"""
Create an ArgumentParser instance with all the config flags
.
def
add
_argument
s_to
_parser
(
cls
,
config_parser
):
"""
Adds all the config flags to an ArgumentParser
.
Doesn
'
t support config-file-generation: used by the worker apps.
Used for workers where we want to add extra flags/subcommands.
Args:
description (str): App description
Returns:
ArgumentParser
config_parser (ArgumentParser): App description
"""
config_parser
=
argparse
.
ArgumentParser
(
description
=
description
)
config_parser
.
add_argument
(
"
-c
"
,
"
--config-path
"
,
...
...
@@ -273,8 +270,6 @@ class Config(object):
# `add_arguments` should be side effect free so this is probably fine.
cls
.
invoke_all_static
(
"
add_arguments
"
,
config_parser
)
return
config_parser
@classmethod
def
load_config_with_parser
(
cls
,
config_parser
,
argv
):
"""
Parse the commandline and config files with the given parser
...
...
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