Compare commits

..
10 Commits
Author SHA1 Message Date
pancake 40f784cd8c fix spaces 2021-06-17 00:31:44 +02:00
pancake e2cd0cd9e2 Fix indent 2021-06-17 00:30:14 +02:00
pancake 400c6d91bd fix lint 2021-06-17 00:29:02 +02:00
pancake 21aca1d8a5 Support var arg parsing 2021-06-17 00:27:09 +02:00
pancake a002a577b4 Implement r2env shell for unix 2021-06-17 00:15:20 +02:00
pancake f097dbb7c5 Fix use 2021-06-17 00:14:59 +02:00
murphy 02e188bf70 Fix r2env use validation 2021-06-16 18:07:30 +02:00
murphy 6a702b428d Fix conflicts 2021-06-16 18:06:46 +02:00
murphy a8118544e3 Fix r2env use, listing installed versions 2021-06-16 17:26:33 +02:00
murphy 740f66ab9b Fix config cmd 2021-06-16 17:26:33 +02:00
2 changed files with 18 additions and 7 deletions

No files matched your search

+5 -2
View File
@@ -90,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
View File
@@ -28,13 +28,15 @@ def show_help():
print_console(HELP_MESSAGE)
actions_with_argument = ["install", "uninstall"]
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,8 +59,13 @@ 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:
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)