mirror of
https://github.com/radareorg/r2env.git
synced 2026-11-08 17:42:22 -10:00
Compare commits
10
Commits
minor_fixes
...
add-shell
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40f784cd8c | ||
|
|
e2cd0cd9e2 | ||
|
|
400c6d91bd | ||
|
|
21aca1d8a5 | ||
|
|
a002a577b4 | ||
|
|
f097dbb7c5 | ||
|
|
02e188bf70 | ||
|
|
6a702b428d | ||
|
|
a8118544e3 | ||
|
|
740f66ab9b |
No files matched your search
+12
-4
@@ -35,7 +35,8 @@ class R2Env:
|
||||
print_console(" [*] {0} ({1})".format(r2_version, r2_path))
|
||||
|
||||
def show_config(self):
|
||||
return json.dumps(self._config)
|
||||
print_console("[*] Current r2env config:")
|
||||
print_console(json.dumps(self._config))
|
||||
|
||||
def list_available_packages(self):
|
||||
print_console("[*] List of available Radare packages")
|
||||
@@ -70,8 +71,12 @@ class R2Env:
|
||||
return
|
||||
self._package_manager.uninstall_package(package)
|
||||
|
||||
def use(self, package):
|
||||
def use(self, package=None):
|
||||
self.exit_if_r2env_not_initialized()
|
||||
if not package:
|
||||
print_console("[x] Package not defined. Please use 'r2env use' with one installed package. ", ERROR)
|
||||
self.list_installed_packages()
|
||||
return
|
||||
cur_ver = self._get_current_version()
|
||||
new_dst_dir = self._package_manager.get_package_path(package)
|
||||
if cur_ver:
|
||||
@@ -85,8 +90,11 @@ class R2Env:
|
||||
with open("version.txt", "r") as version:
|
||||
return version.read()
|
||||
|
||||
def shell(self):
|
||||
pass
|
||||
def shell(self, cmd=""):
|
||||
line = "export PS1=\"r2env\\$ \";export PATH=\"" + self._r2env_path + "/bin:$PATH\"; $SHELL -f"
|
||||
if cmd.strip() == "":
|
||||
return os.system(line)
|
||||
return os.system(line + " -c '" + cmd + "'")
|
||||
|
||||
@staticmethod
|
||||
def _load_config():
|
||||
|
||||
+13
-5
@@ -29,12 +29,14 @@ def show_help():
|
||||
|
||||
|
||||
actions_with_argument = ["install", "uninstall", "use"]
|
||||
actions_with_arguments = ["shell"]
|
||||
actions = {
|
||||
"init": R2Env().init,
|
||||
"version": R2Env().get_r2_path,
|
||||
"config": R2Env().show_config,
|
||||
"list": R2Env().list_available_packages,
|
||||
"install": R2Env().install,
|
||||
"shell": R2Env().shell,
|
||||
"uninstall": R2Env().uninstall,
|
||||
"use": R2Env().use,
|
||||
"versions": R2Env().list_installed_packages,
|
||||
@@ -45,9 +47,10 @@ actions = {
|
||||
def run_action(action, args, use_meson):
|
||||
if action not in actions:
|
||||
print_console("[X] Action not found", ERROR)
|
||||
return
|
||||
if action in actions_with_argument:
|
||||
exit_if_not_argument_is_set(args)
|
||||
elif action in actions_with_arguments:
|
||||
actions[action](" ".join(args))
|
||||
elif action in actions_with_argument:
|
||||
exit_if_not_argument_is_set(args, action)
|
||||
if action == "install":
|
||||
actions[action](args[0], use_meson=use_meson)
|
||||
else:
|
||||
@@ -56,9 +59,14 @@ def run_action(action, args, use_meson):
|
||||
actions[action]()
|
||||
|
||||
|
||||
def exit_if_not_argument_is_set(args):
|
||||
def exit_if_not_argument_is_set(args, action):
|
||||
if len(args) < 1:
|
||||
print_console("[x] Missing package argument.", ERROR)
|
||||
if action == "use":
|
||||
print_console("[x] Package not defined. Please use 'r2env use' with one installed package. ", ERROR)
|
||||
actions["versions"]()
|
||||
else:
|
||||
print_console("[x] Missing package argument. ( as for example: radare2@latest)", ERROR)
|
||||
print_console("[x] Missing package argument. ( as for example: radare2@latest)", ERROR)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user