Throw an error if there are unrecognized arguments
This commit is contained in:
parent
aa387fc57e
commit
262c789754
@ -138,6 +138,7 @@ def assetlink(args):
|
||||
"""
|
||||
Link the asset directory of the currently installed theme and plugins
|
||||
"""
|
||||
commands_util.check_unrecognized_args(args)
|
||||
mgoblin_app = commands_util.setup_app(args[0])
|
||||
app_config = mg_globals.app_config
|
||||
|
||||
|
@ -20,6 +20,7 @@ from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from mediagoblin.db.open import setup_connection_and_db_from_config
|
||||
from mediagoblin.db.migration_tools import MigrationManager
|
||||
from mediagoblin.gmg_commands import util as commands_util
|
||||
from mediagoblin.init import setup_global_and_app_config
|
||||
from mediagoblin.tools.common import import_component
|
||||
|
||||
@ -147,5 +148,6 @@ def run_all_migrations(db, app_config, global_config):
|
||||
|
||||
|
||||
def dbupdate(args):
|
||||
commands_util.check_unrecognized_args(args)
|
||||
global_config, app_config = setup_global_and_app_config(args[0].conf_file)
|
||||
run_dbupdate(app_config, global_config)
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
from mediagoblin import mg_globals
|
||||
from mediagoblin.db.open import setup_connection_and_db_from_config
|
||||
from mediagoblin.gmg_commands import util as commands_util
|
||||
from mediagoblin.storage.filestorage import BasicFileStorage
|
||||
from mediagoblin.init import setup_storage, setup_global_and_app_config
|
||||
|
||||
@ -96,6 +97,7 @@ def env_import(args):
|
||||
'''
|
||||
Restore mongo database and media files from a tar archive
|
||||
'''
|
||||
commands_util.check_unrecognized_args(args)
|
||||
if not args[0].cache_path:
|
||||
args[0].cache_path = tempfile.mkdtemp()
|
||||
|
||||
@ -223,6 +225,7 @@ def env_export(args):
|
||||
'''
|
||||
Export database and media files to a tar archive
|
||||
'''
|
||||
commands_util.check_unrecognized_args(args)
|
||||
if args.cache_path:
|
||||
if os.path.exists(args[0].cache_path):
|
||||
_log.error('The cache directory must not exist '
|
||||
|
@ -63,6 +63,7 @@ def shell(args):
|
||||
"""
|
||||
Setup a shell for the user either a normal Python shell or an IPython one
|
||||
"""
|
||||
commands_util.check_unrecognized_args(args)
|
||||
user_namespace = {
|
||||
'mg_globals': mg_globals,
|
||||
'mgoblin_app': commands_util.setup_app(args[0]),
|
||||
|
@ -32,6 +32,7 @@ def adduser_parser_setup(subparser):
|
||||
|
||||
def adduser(args):
|
||||
#TODO: Lets trust admins this do not validate Emails :)
|
||||
commands_util.check_unrecognized_args(args)
|
||||
commands_util.setup_app(args[0])
|
||||
|
||||
args[0].username = commands_util.prompt_if_not_set(args[0].username, "Username:")
|
||||
@ -67,6 +68,7 @@ def makeadmin_parser_setup(subparser):
|
||||
|
||||
|
||||
def makeadmin(args):
|
||||
commands_util.check_unrecognized_args(args)
|
||||
commands_util.setup_app(args[0])
|
||||
|
||||
db = mg_globals.database
|
||||
@ -91,6 +93,7 @@ def changepw_parser_setup(subparser):
|
||||
|
||||
|
||||
def changepw(args):
|
||||
commands_util.check_unrecognized_args(args)
|
||||
commands_util.setup_app(args[0])
|
||||
|
||||
db = mg_globals.database
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
from mediagoblin import app
|
||||
import getpass
|
||||
import argparse
|
||||
|
||||
|
||||
def setup_app(args):
|
||||
@ -36,5 +37,11 @@ def prompt_if_not_set(variable, text, password=False):
|
||||
variable=raw_input(text + u' ')
|
||||
else:
|
||||
variable=getpass.getpass(text + u' ')
|
||||
|
||||
|
||||
return variable
|
||||
|
||||
|
||||
def check_unrecognized_args(args):
|
||||
if args[1]:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.error('unrecognized arguments: {}'.format(args[1]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user