diff --git a/cd/__init__.py b/cd/__init__.py index 572b36c..de206f7 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -1,7 +1,14 @@ import os +COMMANDS_PREFIX = 'cd-' + + +def cd_list_environment: + for variable, value in os.environ: + print(variable, value) + def install_commands(path): user = '/usr/local/bin' for command in ['list-environment']: - os.symlink(path, os.path.join(user, f'cd-{command}')) + os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}')) diff --git a/cd/__main__.py b/cd/__main__.py index 50e77b6..c93b684 100755 --- a/cd/__main__.py +++ b/cd/__main__.py @@ -7,9 +7,11 @@ import cd if __name__ == '__main__': - command, *_ = sys.argv + command, *arguments = sys.argv command = os.path.basename(command) if command == '__main__.py': cd.install_commands(__file__) else: - print(command) + command = command.replace('-', '_') + function = getattr(cd, command) + function(*arguments)