Onionr/onionr/onionrcommands/parser/arguments.py

64 lines
2.9 KiB
Python
Raw Normal View History

2019-08-29 09:25:21 +00:00
'''
Onionr - Private P2P Communication
Sets CLI arguments for Onionr
'''
'''
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-08-05 04:08:56 +00:00
from .. import onionrstatistics, version, daemonlaunch, keyadders, openwebinterface
2019-08-05 23:09:04 +00:00
from .. import banblocks # Command to blacklist a block by its hash
from .. import filecommands # commands to share files with onionr
from .. import exportblocks # commands to export blocks
from .. import pubkeymanager # commands to add or change id
from .. import resettor # command to reset the tor data directory
2019-08-29 09:25:21 +00:00
from .. import resetplugins # command to reinstall default plugins
2019-07-31 05:10:28 +00:00
import onionrexceptions
2019-08-05 23:09:04 +00:00
from onionrutils import importnewblocks # func to import new blocks
2019-08-04 04:52:57 +00:00
import onionrevents as events
2019-07-31 05:10:28 +00:00
def get_arguments():
'''This is a function because we need to be able to dynamically modify them with plugins'''
args = {
2019-08-05 23:09:04 +00:00
('blacklist', 'blacklist-block', 'remove-block', 'removeblock'): banblocks.ban_block,
2019-07-31 05:10:28 +00:00
('details', 'info'): onionrstatistics.show_details,
2019-08-05 23:09:04 +00:00
('stats', 'statistics'): onionrstatistics.show_stats,
2019-07-31 05:10:28 +00:00
('version'): version.version,
2019-08-04 04:52:57 +00:00
('start', 'daemon'): daemonlaunch.start,
('stop', 'kill'): daemonlaunch.kill_daemon,
2019-08-05 04:08:56 +00:00
('add-address', 'addaddress', 'addadder'): keyadders.add_address,
2019-08-05 23:09:04 +00:00
('openhome', 'gui', 'openweb', 'open-home', 'open-web'): openwebinterface.open_home,
('add-site', 'addsite', 'addhtml', 'add-html'): filecommands.add_html,
('addfile', 'add-file'): filecommands.add_file,
('get-file', 'getfile'): filecommands.get_file,
('export-block', 'exportblock'): exportblocks.export_block,
('importblocks', 'import-blocks', 'import-block'): importnewblocks.import_new_blocks,
2019-08-05 23:09:04 +00:00
('addid', 'add-id'): pubkeymanager.add_ID,
('changeid', 'change-id'): pubkeymanager.change_ID,
2019-08-29 09:25:21 +00:00
('resettor', 'reset-tor'): resettor.reset_tor,
('resetplugins', 'reset-plugins'): resetplugins.reset
2019-08-05 23:09:04 +00:00
2019-07-31 05:10:28 +00:00
}
return args
def get_help():
return
def get_func(argument):
argument = argument.lower()
args = get_arguments()
for arg in args.keys(): # Iterate command alias sets
if argument in arg: # If our argument is in the current alias set, return the command function
return args[arg]
raise onionrexceptions.NotFound