user571099
user571099

Reputation: 1511

list of arguments for executing ruby from command line

I was reading up on running ruby from the command line and found this : How to run ruby programs on Windows 7?

one of the answers said that

the general form of a ruby command is:

ruby [ruby options] [program name] [program options]

I tried looking online for these [ruby options] but could not find any. Do you guys have a list of these ruby options or at least helpful links?

Upvotes: 1

Views: 250

Answers (3)

sawa
sawa

Reputation: 168101

Arup's answer already gives some, but see here for some more. Namely, here are the ones that are missing in Arup's answer:

-h   Displays an overview of command-line options.
-K [ kcode] Specifies the multibyte character set code (e or E for EUC (extended Unix code); s or S for SJIS (Shift-JIS); u or U for UTF-8; and a, A, n, or N for ASCII).
-X dir   Changes directory before executing (equivalent to -C).
-y   Enables parser debug mode.
--debug  Enables debug mode (equivalent to -d).
--help   Displays an overview of command-line options (equivalent to -h).
--verbose    Enables verbose mode (equivalent to -v). Sets $VERBOSE to true
--yydebug    Enables parser debug mode (equivalent to -y).

Upvotes: 1

Arup Rakshit
Arup Rakshit

Reputation: 118271

Open your command prompt and type ruby -h, you will get all as below :

C:\>ruby -h
Usage: ruby [switches] [--] [programfile] [arguments]
  -0[octal]       specify record separator (\0, if no argument)
  -a              autosplit mode with -n or -p (splits $_ into $F)
  -c              check syntax only
  -Cdirectory     cd to directory, before executing your script
  -d              set debugging flags (set $DEBUG to true)
  -e 'command'    one line of script. Several -e's allowed. Omit [programfile]
  -Eex[:in]       specify the default external and internal character encodings
  -Fpattern       split() pattern for autosplit (-a)
  -i[extension]   edit ARGV files in place (make backup if extension supplied)
  -Idirectory     specify $LOAD_PATH directory (may be used more than once)
  -l              enable line ending processing
  -n              assume 'while gets(); ... end' loop around your script
  -p              assume loop like -n but print line also like sed
  -rlibrary       require the library, before executing your script
  -s              enable some switch parsing for switches after script name
  -S              look for the script using PATH environment variable
  -T[level=1]     turn on tainting checks
  -v              print version number, then turn on verbose mode
  -w              turn warnings on for your script
  -W[level=2]     set warning level; 0=silence, 1=medium, 2=verbose
  -x[directory]   strip off text before #!ruby line and perhaps cd to directory
  --copyright     print the copyright
  --version       print the version

Upvotes: 4

Alexander van Oostenrijk
Alexander van Oostenrijk

Reputation: 4764

Here are Ruby's command-line options:

Usage: ruby [switches] [--] [programfile] [arguments]
-0[octal]       specify record separator (\0, if no argument)
-a              autosplit mode with -n or -p (splits $_ into $F)
-c              check syntax only
-Cdirectory     cd to directory, before executing your script
-d              set debugging flags (set $DEBUG to true)
-e 'command'    one line of script. Several -e's allowed. Omit [programfile]
-Eex[:in]       specify the default external and internal character encodings
-Fpattern       split() pattern for autosplit (-a)
-i[extension]   edit ARGV files in place (make backup if extension supplied)
-Idirectory     specify $LOAD_PATH directory (may be used more than once)
-l              enable line ending processing
-n              assume 'while gets(); ... end' loop around your script
-p              assume loop like -n but print line also like sed
-rlibrary       require the library, before executing your script
-s              enable some switch parsing for switches after script name
-S              look for the script using PATH environment variable
-T[level=1]     turn on tainting checks
-v              print version number, then turn on verbose mode
-w              turn warnings on for your script
-W[level=2]     set warning level; 0=silence, 1=medium, 2=verbose
-x[directory]   strip off text before #!ruby line and perhaps cd to directory
--copyright     print the copyright
--version       print the version

Upvotes: 0

Related Questions