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

How to Pass Command Line Arguments? #4

Open
jrg94 opened this issue Oct 16, 2023 · 2 comments · May be fixed by #5
Open

How to Pass Command Line Arguments? #4

jrg94 opened this issue Oct 16, 2023 · 2 comments · May be fixed by #5

Comments

@jrg94
Copy link

jrg94 commented Oct 16, 2023

I currently maintain the Sample Programs repo, and I'm looking to expand our collection of Pyret scripts. I quite like the language, but I'm running into an issue where I can't seem to figure out how to provide command line arguments. We use this npm package in a Docker image, so we can run Pyret scripts. Is there a way to pass arguments to this compiler? Here are all the files and whatnot for reference:

A simple script that I'd like to implement is capitalize which just capitalizes the first letter of a user's input and prints the result. The script itself is pretty straightforward to write, but I can't figure out how to get something like the following to work:

pyret -qk capitalize.arr "capitalize"

Unfortunately, the command above produces the help dialog instead. After digging through docs, I was unable to solve this problem. Others seem to be having the same issue. Any help would be greatly appreciated!

@rzuckerm
Copy link

@jrg94 Actually, I think this can be done like this:

pyret -qkc capitalize.arr
node capitalize.arr "capitalize"

The first command compiles capitalize.arr to capitalize.jarr, which can be run by node with command-line arguments. You can parse the command-line arguments using this to get the command-line arguments:

import cmdline-lib as CL
args = CL.command-line-arguments()

@jrg94
Copy link
Author

jrg94 commented Dec 27, 2023

Clever! I like this solution.

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

Successfully merging a pull request may close this issue.

2 participants