1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from mediagoblin
.tools
.common
import import_component
24 'setup': 'mediagoblin.gmg_commands.shell:shell_parser_setup',
25 'func': 'mediagoblin.gmg_commands.shell:shell',
26 'help': 'Run a shell with some tools pre-setup'},
28 'setup': 'mediagoblin.gmg_commands.migrate:migrate_parser_setup',
29 'func': 'mediagoblin.gmg_commands.migrate:migrate',
30 'help': 'Apply all unapplied bulk migrations to the database'},
32 'setup': 'mediagoblin.gmg_commands.users:adduser_parser_setup',
33 'func': 'mediagoblin.gmg_commands.users:adduser',
34 'help': 'Creates an user'},
36 'setup': 'mediagoblin.gmg_commands.users:makeadmin_parser_setup',
37 'func': 'mediagoblin.gmg_commands.users:makeadmin',
38 'help': 'Changes a user\'s password'},
40 'setup': 'mediagoblin.gmg_commands.users:changepw_parser_setup',
41 'func': 'mediagoblin.gmg_commands.users:changepw',
42 'help': 'Makes admin an user'},
44 'setup': 'mediagoblin.gmg_commands.wipealldata:wipe_parser_setup',
45 'func': 'mediagoblin.gmg_commands.wipealldata:wipe',
46 'help': 'Wipes **all** the data for this MediaGoblin instance'},
48 'setup': 'mediagoblin.gmg_commands.import_export:import_export_parse_setup',
49 'func': 'mediagoblin.gmg_commands.import_export:env_export',
50 'help': 'Exports the data for this MediaGoblin instance'},
52 'setup': 'mediagoblin.gmg_commands.import_export:import_export_parse_setup',
53 'func': 'mediagoblin.gmg_commands.import_export:env_import',
54 'help': 'Exports the data for this MediaGoblin instance'},
59 parser
= argparse
.ArgumentParser(
60 description
='GNU MediaGoblin utilities.')
62 '-cf', '--conf_file', default
='mediagoblin.ini',
63 help="Config file used to set up environment")
65 subparsers
= parser
.add_subparsers(help='sub-command help')
66 for command_name
, command_struct
in SUBCOMMAND_MAP
.iteritems():
67 if command_struct
.has_key('help'):
68 subparser
= subparsers
.add_parser(
69 command_name
, help=command_struct
['help'])
71 subparser
= subparsers
.add_parser(command_name
)
73 setup_func
= import_component(command_struct
['setup'])
74 exec_func
= import_component(command_struct
['func'])
78 subparser
.set_defaults(func
=exec_func
)
80 args
= parser
.parse_args()
84 if __name__
== '__main__':