Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.

For parsing command line arguments intelligently, see Parsing command-line arguments.

Example command line:

myprogram -c "alpha beta" -h "gamma"

[indent=4]
/*
   Command line arguments, in Genie
 
   valac commandLine.gs
   ./commandLine sample arguments 'four in total here, including args 0'
*/
 
init
 
    // Output the number of arguments
    print "%d command line argument(s):", args.length
 
    // Enumerate all command line arguments
    for s in args
        print s
 
    // to reiterate, args[0] is the command
    if args[0] is not null
        print "\nWith Genie, args[0] is the command: %s", args[0]