1

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?

1
  • @tuxdna Yes.. Exactly...! Commented Jan 7, 2014 at 14:42

3 Answers 3

4

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
Sign up to request clarification or add additional context in comments.

2 Comments

An extended description of the options for the ruby command can be found in the ruby(1) man page.
@toro2k Yes.. I will update.. Once I will be at home.. As in my workplace I do have windows machine only.. :(
1

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).

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.