environ
Some checks failed
/ job (push) Failing after 7s

This commit is contained in:
Marc Beninca 2024-04-26 23:55:20 +02:00
parent 76840937d1
commit fbf4141fb3
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 12 additions and 3 deletions

View file

@ -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}'))

View file

@ -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)