Skip to content

Calling Sinan From The Shell

Eric Merritt edited this page Dec 12, 2011 · 1 revision

Calling Sinan From The Shell

The erlang shell is an extraordinarily useful tool that you should be using. Sinan makes the shell very easy to use by giving you the sinan shell task that opens up a shell that has all of the paths for your project correctly setup.

When you are in the shell often you may wish to call sinan to manipulate the project without leaving the shell and reexecuting sinan on the command line. To that end sinan provides a simple shell oriented api for you to use. To use this api simply execute the following function in the shell:

1> sinan:do(<task>).

This will allow you to run the task specified directly in your shell. Lets so an example of running the eunit task on a real project.

$> sinan shell

Eshell V5.8.5  (abort with ^G)
1> sinan:do(eunit).
starting: depends

compile time dependencies:

compiler                  4.7.5      : /var/stow/otp_R14B04/lib/erlang/lib/compiler-4.7.5
proper                    1.0        : /var/stow/otp_R14B04/lib/erlang/lib/proper-1.0
eunit                     2.2.1      : /var/stow/otp_R14B04/lib/erlang/lib/eunit-2.2.1

runtime dependencies:

kernel                    2.14.5     : /var/stow/otp_R14B04/lib/erlang/lib/kernel-2.14.5
stdlib                    1.17.5     : /var/stow/otp_R14B04/lib/erlang/lib/stdlib-1.17.5
erlware_commons           0.6.0      : /var/stow/otp_R14B04/lib/erlang/lib/erlware_commons-0.6.0

project applications:

seresye                   0.0.3      : /home/emerritt/workspace/seresye/_build/seresye/lib/seresye-0.0.3
starting: build
starting: eunit
Eunit testing app seresye
testing seresyet_simple_relatives
  Test passed.
testing seresyet_sieve
  Test passed.
testing seresyet_sample
  There were no tests to run.
testing seresyet_relatives
  Test passed.
testing seresyet_cannibals
  Test passed.
testing seresyet_13
  There were no tests to run.
testing seresyet_12
  There were no tests to run.
ok
2>

As you can see, it gives you the exact same result as running it on the system command line. You can do this with any task that sinan supports even plug-in tasks.

Options

There are times when you might want to pass options sinan. You may do this through a second options argument that supports the following key value pairs.

Verbose: Be verbose about what gets done

{verbose, true | false}

Start Dir: The search location for the project (basically some directory in the project, this is only useful if you want to run the command in a different directory then you are in).

{start_dir, string()}

User Dir: The user directory to use (only useful if the user directory is different then the system default).

 {user_dir, string()}

Release Name: The release to build

 {release, string()}

Project Name: Used if there is no sinan.config and the project name can not be inferred.

 {project, string()}

Project Version: Used if there is no sinan.config and the project version can not be inferred.

{version, string()}

So, for example, if I wanted to pass verbose and a start_dir when calling the eunit task I could do.

1> sinan:do(eunit, [{verbose, true}, {start_dir, "some-fine-dir/foo"}]).

and get the same results that I would have if I did this on the command line:

$> sinan -v true -s some-fine-dir/foo eunit