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

[question] How to get the parameters of a task? Is it possible? #23

Closed
jabbalaci opened this issue Dec 13, 2019 · 3 comments
Closed

[question] How to get the parameters of a task? Is it possible? #23

jabbalaci opened this issue Dec 13, 2019 · 3 comments

Comments

@jabbalaci
Copy link

I would like to use pynt for a Java project. The caller task looks like this:

@task()
def run():
    cmd = "java -cp build/classes/java/main adder.Adder"
    print(cmd)
    os.system(cmd)

Let's suppose that we can pass command-line arguments to the Java program:

bash$ java -cp build/classes/java/main adder.Adder 5 6
11

and it adds them together. Would it be possible to pass these arguments to a task and then forward them to the Java program? I want a call like this:

bash$ pynt run 5 6
11

At the moment pynt thinks that "5" is another task and drops an error that it doesn't exist.

@rags
Copy link
Owner

rags commented Dec 14, 2019 via email

@jabbalaci
Copy link
Author

Thanks, I found it. I put it here for future references:

@task()
def run(*args, **kwargs):
    params = " ".join(args)
    cmds = [
        "./add.py {}".format(params)
    ]
    for cmd in cmds:
        call_external_command(cmd)

Normal call:

bash$ ./add.py 5 6
11

Call it via pynt:

bash$ pynt "run[5, 6]"

However, this syntax is quite strange. Other build systems, like Rust's cargo, accept parameters like this: "cargo run 5 6".

@rags
Copy link
Owner

rags commented Dec 14, 2019 via email

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