Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Add support for Pinecone programs to get command line args #12

Closed
raclettes opened this issue Apr 24, 2017 · 11 comments
Closed

Add support for Pinecone programs to get command line args #12

raclettes opened this issue Apr 24, 2017 · 11 comments

Comments

@raclettes
Copy link
Contributor

I've seen a previous commit that allowed command line argument support, but how do I use these arguments in a program?

@wmww
Copy link
Owner

wmww commented Apr 24, 2017

That commit was for controlling the interpreter with arguments there is currently not support for giving your program arguments. I will update this issue when I implement this.

@raclettes
Copy link
Contributor Author

ok, i will be sure to check by later

@wmww wmww changed the title I know there is support. Add support for Pinecone programs to get command line args Apr 25, 2017
@raclettes
Copy link
Contributor Author

I'll try and add this myself soon. If you want.

@wmww
Copy link
Owner

wmww commented Jul 5, 2017

Go for it. Sorry I haven't added it, I haven't worked on Pinecone much lately.

@wmww
Copy link
Owner

wmww commented Jul 5, 2017

on lines 193 and 227 in src/main.cpp I set i (the current command line arg being processed) to argc (the cont of the arguments. To implement command line args, make a vector of strings in the Flags struct (in main.cpp), fill that with all the arguments that come after the -e or -r flag and then expose that as a builtin global variable.

@wmww
Copy link
Owner

wmww commented Jul 5, 2017

On second thought, you might want to make the args vector a global, so you can access it in PineconeStdLib.cpp where you can expose it. If you have any trouble implementing it, let me know.

@raclettes
Copy link
Contributor Author

Currently out, when I get home I'll implement that and then merge.

@raclettes
Copy link
Contributor Author

i haven't used c++ in a while.

But i gave it a go, from what i can remember.

here

@raclettes
Copy link
Contributor Author

It is very much a WIP change.

You're probably better to do it, you know in better detail how you want it to work.

@wmww wmww mentioned this issue Jul 12, 2017
@wmww
Copy link
Owner

wmww commented Jul 12, 2017

Your patch looks good but still needs some stuff I will add (as per my comment on the PR)

Also, a different system needs to be created for argument parsing when transpiled. For starters, when transpiling and automatically running the arguments after the -e must be carried along to the executed binary. This can be done by using this function on your args vector and appending it to the executed command around here. You can do that on your patch branch if you want. There is other stuff that's needed in the transpiled code, but that's a bit complicated. I'll look into it later.

@wmww
Copy link
Owner

wmww commented Jul 12, 2017

Merged in your PR with my additions and fixes. It now supports command line args both when compiled or interpreted. Documentation for this feature is at the end of the temporary hacks tutorial.

@wmww wmww closed this as completed Jul 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants