2019-07-30 18:13:10 +00:00
|
|
|
'''
|
|
|
|
Onionr - Private P2P Communication
|
|
|
|
|
|
|
|
This module loads in the Onionr arguments and their help messages
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
'''
|
2019-07-31 05:10:28 +00:00
|
|
|
import sys
|
2019-07-30 18:13:10 +00:00
|
|
|
from etc import onionrvalues
|
2019-07-31 05:10:28 +00:00
|
|
|
import logger, onionrexceptions
|
2019-08-05 00:34:57 +00:00
|
|
|
import onionrplugins
|
|
|
|
import onionrpluginapi
|
2019-07-31 05:10:28 +00:00
|
|
|
from . import arguments, recommend
|
2019-08-05 00:34:57 +00:00
|
|
|
|
|
|
|
def register_plugin_commands(cmd):
|
|
|
|
cmd = 'on_%s_cmd' % (cmd,)
|
|
|
|
for pl in onionrplugins.get_enabled_plugins():
|
|
|
|
pl = onionrplugins.get_plugin(pl)
|
|
|
|
if hasattr(pl, cmd):
|
|
|
|
getattr(pl, cmd)(onionrpluginapi.PluginAPI)
|
|
|
|
return True
|
|
|
|
|
2019-07-30 18:13:10 +00:00
|
|
|
def register():
|
2019-08-02 23:00:04 +00:00
|
|
|
try:
|
|
|
|
cmd = sys.argv[1]
|
|
|
|
except IndexError:
|
|
|
|
cmd = ""
|
2019-07-31 05:10:28 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
arguments.get_func(cmd)()
|
|
|
|
except onionrexceptions.NotFound:
|
2019-08-05 00:34:57 +00:00
|
|
|
if not register_plugin_commands(cmd):
|
|
|
|
recommend.recommend()
|
|
|
|
sys.exit(3)
|