Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offering: Update the run function to allow for command line arguments #46

Open
jdhedden opened this issue May 9, 2022 · 1 comment
Open

Comments

@jdhedden
Copy link

jdhedden commented May 9, 2022

The run function currently only works a single word, so trying to use command line argument with a command doesn't work (e.g., 'chmod 755'). The version adds that capability:

@register("run")
@typed(T_ARRAY, T_VOID)
def run(command, inp):
    command = dynamic_cast(T_STRING, command).value.split()
    args = map(T_STRING.create_from, inp)
    args = list(map(lambda v: v.value, args))

    print("Running '{}' with arguments {}".format(command, args))
    subprocess.call(command + args)

For README.md:

### Usage of `run`

The `run` *function* executes a command over arguments presented:

/usr/bin/ls -1 ft/ft/*.py | map run 'chmod 644'
Running '['chmod', '644']' with arguments ['ft/ft/command.py']
Running '['chmod', '644']' with arguments ['ft/ft/error.py']
Running '['chmod', '644']' with arguments ['ft/ft/functions.py']
Running '['chmod', '644']' with arguments ['ft/ft/init.py']
Running '['chmod', '644']' with arguments ['ft/ft/internal.py']
Running '['chmod', '644']' with arguments ['ft/ft/termcolor.py']
Running '['chmod', '644']' with arguments ['ft/ft/test_command.py']
Running '['chmod', '644']' with arguments ['ft/ft/types.py']
Running '['chmod', '644']' with arguments ['ft/ft/version.py']

@sharkdp
Copy link
Owner

sharkdp commented May 22, 2022

Thanks. Please see the other tickets regarding the maintenance status of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants