Version 2 (modified by Chuck, 12 years ago)


Command Line

Quick examples:

  # compile and run immediately (if no errors)
cobra myprog.cobra

  # get help
cobra -h

  # compile only
cobra -c myprog.cobra

  # with debug
cobra -d -c myprog.cobra

  # multiple source files
cobra -c foo.cobra bar.cobra

  # passing arguments
cobra foo.cobra bar.cobra -- arg1 arg2

  # disable all checks, contracts, asserts, etc.
  # maximum performance
cobra -turbo foo.cobra

Getting help:

cobra -h


cobra -help

will dump a page detailing all the command line options supported.

The compiler runs for each invocation in a particular mode of operation. These correspond to the 'commands on paths'

  • -compile or -c - compile the provided files and bind into an executable
  • -run-exe or -r - as for -compile but run the executable after successful compilation. This is the default mode if none other is given
  • -test - as for -compile but run the executables test cases after successful execution
  • -document - parse the provided files and generate documentation from the parse tree

In addition there are three standalone commands

  • -help or -h - display the cobra commandline options and descriptions
  • -about - display info about cobra
  • -version - display the cobra executables version information

Commandline items that are not options ( begin with '-') are taken to be filenames. Cobra can take one or a list of commandline given files to compile and the files can be cobra code ( filename ends in '.cobra') or C# code ( filename ends in '.cs'). Filenames without any extension are assumed to be a cobra code file of the same name with a '.cobra' extension


cobra myProg.cobra 
cobra myProg

both do the same thing - compile a cobra code file myProg.cobra to an executable and run it (if compilation succeeds)


options form : -option:value, synonyms

TODO Sections

  • Files:file
  • Controlling type of executable built -target/-t
  • Providing references and library search path -reference/-ref -library-directory/-lib -embed-run-time/-ert
  • Controlling compilation -include-{asserts, nil-checks, tests}
    • -optimize/-o -debug/-d -turbo/-t
    • -keep-intermediate-files/-kif
    • -contracts -verbosity/-v
  • Specifying executable and args for it -run-args/-- and -run
  • Error handling -detailed-stack-trace/dst -debugging-tips -exception-report -reveal-internal-exceptions
  • Development cycle - colorize -editor
  • Back end -sharp-compiler -sharp-args


Working with Multiple Files

For now, see:

See also: LanguageTopics, LibraryTopics