Skip to main content
Engineering LibreTexts

1.3: Handling Command Line Options

  • Page ID
    43780
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    We have a brand new and nice way to handle command line arguments. It is self-documented and easily extendable. Let us have a look at how the command line is handled. As usual we will start by showing you how to find your way alone.

    How to find our way

    Because we highly value self-documentation, just use the --help option to get an explanation.

    ./pharo Pharo.image --help
    

    It will produce the following output.

    Usage: [<subcommand>] [--help] [--copyright] [--version] [--list]
        --help print this help message
        --copyright print the copyrights
        --version print the version for the image and the vm
        --list list a description of all active command line handlers
        <subcommand> a valid subcommand in --list
    
    Documentation:
    A DefaultCommandLineHandler handles default command line arguments and options.
    The DefaultCommandLineHandler is activated before all other handlers.
    It first checks if another handler is available. If so it will activate the found handler.
    

    System version and handler list

    Two of the default options are important versions and list. Let us have a look at them now.

    Getting system version. A typical and important command line option is --version. Please use it when you report bugs and deviant behavior.

    ./pharo Pharo.image --version
    M: NBCoInterpreter NativeBoost-CogPlugin-IgorStasenko.15 uuid: 44b6b681-38f1-
        4a9e-b6ee-8769b499576a Dec 18 2012
    NBCogit NativeBoost-CogPlugin-IgorStasenko.15 uuid: 44b6b681-38f1-4a9e-b6ee-
        8769b499576a Dec 18 2012
    git://gitorious.org/cogvm/blessed.git Commit: 452863
        bdfba2ba0b188e7b172e9bc597a2caa928 Date: 2012-12-07 16:49:46 +0100 By:
        Esteban Lorenzano <estebanlm@gmail.com> Jenkins build #5922 
    

    The --version argument gives the version of the virtual machine. If you wish to obtain the version of the image, then you need to open the image, use the World menu, and select About.

    List of available handlers. The command line option --list lists of the current option handlers. This list depends on the handlers that are currently loaded in the system. In particular, it means that you can simply add a handler for your specific situation and wishes.

    The following list shows the available handlers.

    ./pharo Pharo.image --list
    
    Currently installed Command Line Handlers:
        st                Loads and executes .st source files
        Fuel              Loads fuel files
        config            Install and inspect Metacello Configurations from the command line
        save              Rename the image and changes file
        test              A command line test runner
        update            Load updates
        printVersion      Print image version
        eval              Directly evaluates passed in one line scripts
    

    Loading Metacello Configuration. To get some explanation about the use of the config option, just request its associated help as follows.

    ./pharo Pharo.image config --help
    

    Note that this help is the one of the associated handler, not one of the command line generic system.

    Usage: config [--help] <repository url> [<configuration>] [--install[=<version>]] [--
            group=<group>] [--username=<username>] [--password=<password>]
        --help                show this help message
        <repository url>      A Monticello repository name
        <configuration>       A valid Metacello Configuration name
        <version>             A valid version for the given configuration
        <group>               A valid Metacello group name
        <username>            An optional username to access the configuration's repository
        <password>            An optional password to access the configuration's repository
    
    Examples:
        # display this help message
        pharo Pharo.image config
    
        # list all configurations of a repository
        pharo Pharo.image config $MC_REPOS_URL
    
        # list all the available versions of a confgurtation
        pharo Pharo.image config $MC_REPOS_URL ConfigurationOfFoo
    
        # install the stable version
        pharo Pharo.image config $MC_REPOS_URL ConfigurationOfFoo --install
    
        #install a specific version '1.5'
        pharo Pharo.image config $MC_REPOS_URL ConfigurationOfFoo --install=1.5
    
        #install a specific version '1.5' and only a specific group 'Tests'
        pharo Pharo.image config $MC_REPOS_URL ConfigurationOfFoo --install=1.5 --
            group=Tests
    

    This page titled 1.3: Handling Command Line Options is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.