This lesson is still being designed and assembled (Pre-Alpha version)

NEMO's command line interface (CLI)

Overview

Teaching: 5 min
Exercises: 5 min
Questions
  • How do I use NEMO from the command line

Objectives
  • Learning NEMO command line interface

Any NEMO command can be run from the command line. Here is the tsf (“type structured file”) program, which would display the contents of NEMO’s binary files in some human readable way. So lets try issuing the command

$ tsf 
Insufficient parameters, try 'help=', 'help=?' or 'help=h' or 'man tsf',
Formatted man page might also be here: https://teuben.github.io/nemo/man_html/tsf.1.html
Usage: tsf in=??? ...
type contents of a (binary) structured file

so obviously it needs some arguments. And there some reminders on how and where to get more help:

$ tsf --help

give

tsf in=??? maxprec=false maxline=4 allline=false indent=2 margin=72 item= xml=f octal=f VERSION=3.3c

Keyword Order

The order of the keywords can be important, as the keyword= portion can be left off if given in this order. However, from the moment a keyword is named, they all need to be named. python has a similar philosphy. An example of this:

$ tsf foo.dat true 10 margin=80 item=Image

Getting More Help

More help can also be obtained via the help= option. Try for yourself the help=h and help=M options for the tsf program.

The help=? gives help what help options exist. If your shell gets confused by the question mark, try help=\?

Solution

The help=h will give you a line by line summary of the keyword, some one-line help and the default in square brackets.

         tsf help=h
         margin           : righthand margin  [72]
         in               : input file name  [???]
         maxprec          : print nums with max precision  [false]
         maxline          : max lines per item  [4]
         allline          : print all lines (overrides maxline)  [false]
         indent           : indentation of compound items  [2]
         margin           : righthand margin  [72]
         item             : Select specific item []
         xml              : output data in XML format? (experimental) [f]
         octal            : Force integer output in octal again? [f]
         VERSION          : 3-feb-2014 PJT  [3.3c]

The help=M will give you a classic unix man page

         tsf help=h

        TSF(1NEMO)

        NAME
             tsf - type a structured file

        SYNOPSIS
             tsf in=file [parameter=value] ...

        DESCRIPTION
             tsf types  the contents of a structured binary file . . .
        . . .

Such a Unix manual page - short of reading the source code - will have the most information, including examples, and sometimes a TLDR section.

Source Code?

Ultimately the best documentation can be the source code. In the remainder of this episode you will discover how to easily find and look at the source code

mknemo

The mknemo command will help in updating NEMO when new code is available

      mknemo tsf

will not only compile a new version of the tsf program, but also show where the source code lives. Have a look at the source code with your favorite Unix command or editor.

Solution

      MKNEMO> Searching tsf.c: 
      found one: /home/teuben/NEMO/nemo/src/kernel/io/tsf.c
      gcc -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -fpic -rdynamic  -Dlinux -DSYSV  -I/home/teuben/NEMO/nemo/inc -I/home/teuben/NEMO/nemo/lib -I/home/teuben/NEMO/nemo/opt/include -I/usr/include/hdf   -Wall -Wimplicit-function-declaration  -D_GNU_SOURCE -std=c99  -o tsf tsf.c -L/home/teuben/NEMO/nemo/lib -L/home/teuben/NEMO/nemo/opt/lib          -lnemo -ldl  -lreadline -lhistory -lncurses `pkg-config --libs cfitsio` -lm   -L/usr/lib/gcc/x86_64-linux-gnu/11 -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/11/../../.. -lgfortran -lm -lquadmath 

On the 2nd line you will see the filename, so in my case I can do

       more /home/teuben/NEMO/nemo/src/kernel/io/tsf.c

Key Points

  • Run a NEMO command

  • Get help from a NEMO command