Access Command Line arguments

How Can I access Command line arguments in mojo like we do in python using sys:
import sys
print(sys.argv[1])
import sys
print(sys.argv[1])
Trying the same in mojo:
import sys

fn main() raises:
print(sys.argv[1])
import sys

fn main() raises:
print(sys.argv[1])
Yeilds the following error: error: 'argv' expects 0 input parameters, but 1 was specified print(sys.argv[1])
2 Replies
benny
benny8mo ago
Simple fix, you’ll need to add () to indicate a function call in your mojo code
import sys

fn main() raises:
print(sys.argv()[1])
import sys

fn main() raises:
print(sys.argv()[1])
Want results from more Discord servers?
Add your server