Programming languages C Java Perl AWK PHP Python Racket
References
Different Command-line argument parsing methods are used by different programming languages to parse command-line arguments.
Programming languages
C
{{Main|C_syntax#Command-line_arguments}}
C uses argv to process command-line arguments.[1][2]
An example of C argument parsing would be:
Java
An example of Java argument parsing would be:
Perl
Perl uses $ARGV.
or
AWK
AWK uses ARGV also.
PHP
PHP uses argc as a count of arguments and argv as an array containing the values of the arguments.[3][4] To create an array from command-line arguments in the -foo:bar format, the following might be used:
PHP can also use getopt().[5]
Python
Python uses sys.argv, e.g.:
Python also has a module called argparse in the standard library for parsing command-line arguments.[6]
Racket
Racket uses a current-command-line-arguments parameter, and provides a racket/cmdline[7] library for parsing these arguments. Example:
The library parses long and short flags, handles arguments, allows combining short flags, and handles -h and --help automatically:
References
1. ^{{cite web|url=http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html |title=The C Book — Arguments to main |publisher=Publications.gbdirect.co.uk |date= |accessdate=2010-05-31}} 2. ^An example of parsing C arguments and options 3. ^{{cite web|url=http://php.net/manual/en/reserved.variables.argv.php |title=PHP Manual |publisher=PHP |date= |accessdate=2010-05-31}} 4. ^PHP Programming/CLI 5. ^https://php.net/getopt 6. ^{{cite web|title=argparse — Parser for command-line options, arguments and sub-commands|url=https://docs.python.org/library/argparse.html|work=Python v2.7.2 documentation|accessdate=7 March 2012}} 7. ^The Racket reference manual, Command-Line Parsing
5 : Command shells|Articles with example Java code|Articles with example PHP code|Articles with example Python code|Articles with example Racket code