Command Line Syntax
Command Line Syntax
Source Insight's command line has the following syntax: sourceinsight4 [-option] [ [+linenumber file] [+file] [file] [symbolname] ]
Optional parameters are shown here inside […] brackets. Any number of options, files, and symbol names may be given on the command line.
Each option given on the command line must be preceded by a dash (-) or a forward slash (/).
Specifying File Arguments
Each "file" argument may be one of the following types:
•
A regular file name. If more than one file exists with that name, then a list will be shown and you will be able to pick the exact file.
•
A symbol name. Since Source Insight treats file names as symbols, each file argument can be more generally thought of as a symbol. Source Insight will open the file where the symbol lives and jump to its location. You may specify any number of symbols. If the symbol name conflicts with file names
(without extensions), or with other symbols, then a list will be shown and you will be able to pick the exact symbol instance.
•
The name of a workspace file, including the .siwork extension. Source Insight will open all the files contained in the workspace.
Opening Files
On the Source Insight command line, you can specify files following the options. Each file name may be optionally preceded by a plus sign (+) and a line number. If this is done, the file will be displayed with that line number visible.
For example: sourceinsight4 +100 file.c
This will open file.c
and position the file so that line 100 is visible.
Opening an Additional File
Each file name may be optionally preceded with a plus sign (+) only. In this case, the file is opened along with the other files in the current workspace.
For example: sourceinsight4 +file.c
This will open file.c
along with all the files previously open in the current workspace.
If one or more files are specified on the command line without the plus sign prefix, then the files previously open in the current workspace are not opened. Instead, only the files specified on the command line are opened.
For example: sourceinsight4 file.c other.c
This will open only file.c
and other.c
. The previously opened files in the current workspace are not opened.
Source Insight 4 User Guide 127
Command Line Syntax
Jumping to a Symbol Definition
If you specify a symbol name that does not happen to conflict with a file name, then Source Insight will open the correct file and jump to the definition. For example: sourceinsight4 OpenTcpPort
This will open the file containing OpenTcpPort and jump to its definition. You can combine multiple symbols on the command line.
How a File is Located
When a relative file name path is given on the command line, Source Insight first tries to find the file relative to the directory that you started Source Insight in. If it can't find the file and a project is open, it looks for the file in the project's file list.
In other words, you can start Source Insight in any directory and give it a file name, and if the file is in the current project, Source Insight should find it. If there happens to be a file with the same name in the startup directory (or relative to it), then Source Insight will open that file.
Opening Workspaces
In addition to regular text files, you may also specify the name of a workspace file for Source Insight to open.
For example: sourceinsight4 myset.siwork
This will open all the files in the workspace file myset.siwork.
Any number of workspace file names may also be intermixed with regular file names.
For example: sourceinsight4 +100 file.c myset.vw print.c myset2.siwork
This will open both the files and the workspace files.
Command Line Options
The following options may be included on the Source Insight command line.
Suppressing New Program Instances
-i <rest of command line>
This option will direct the rest of the command line to an already running instance of Source Insight, if any. If there are no instances already running, then a new instance is started.
Example: sourceinsight4 –i myfile.cpp
This will locate an already running instance of Source Insight, and tell it to open myfile.cpp.
Always Starting a New Program Instance
-ni <rest of command line>
This option will start a new instance of Source Insight, even if one is already running.
Example: sourceinsight4 -ni myfile.cpp
Normally, if you invoke Source Insight with one or more file name on the command line, and another instance of Source Insight is already running, then the files will open in the existing instance of Source
Insight. A new Source Insight instance is not launched. This option forces a new instance to launch.
128 Source Insight 4 User Guide
Command Line Syntax
Running a Source Insight Command
-c <command-name>
This option will start Source Insight, and run the specified command. The command can be a built-in command, or a defined custom command, or a macro command.
To invoke a macro command, use the name of the macro function, but do not include parentheses. There is no way to pass parameters to a macro function from the command line. For example: sourceinsight4 -c MyMacroFunction
Specifying a Project to Open
-p <project-name>
This option closes the current project, if any, and opens the project given in project-name
. If the project does not exist, Source Insight will give an error message.
Example: sourceinsight4 -p myproj
Closing the Current Project
-pc
This option closes the current project if one is open. No other project is opened.
Example: sourceinsight4 -pc
Using a Temporary Project
-pt <projectname>
This option closes the current project, if any, and opens the project given in projectname
. Unlike the
-p option, the next time you run Source Insight, the old current project is opened. This is useful if you want to put a Source Insight command in a batch file, but don't want the current project to be changed.
Example: sourceinsight4 -pt mail
Finding a Symbol
-f <symbol_name>
This option locates the symbol given in symbol_name
, opens that file, and positions the insertion point on the symbol. If the symbol can't be found, Source Insight will give an error message. This is unlike specifying a symbol in place of a file name because this explicitly tells Source Insight that you are looking for a parsed symbol, not a file.
Example: sourceinsight4 -f DoIdle
Synchronizing Project Files
-u
This option updates all project files right away when Source Insight starts. It is exactly like using the Synchro-
nize Files
command on the Project menu.
Example: sourceinsight4 -u
Synchronizing Files in Batch Mode
-ub
This option is like -u except that Source Insight quits after the files are updated. This is useful for putting a command in a batch file to synchronize Source Insight projects.
Source Insight 4 User Guide 129
Command Line Syntax
Example: sourceinsight4 –ub
Suppressing the Splash Screen
-s
This option turns off the Source Insight splash screen that normally appears when starting up.
Comparing Files
-d <file1> <file2>
This option open the File Compare window and compares the two given files. See “File Compare” on page 199.
Resetting All Settings
-reset
This option tells Source Insight to reset all optional settings: the configuration, the layout, and any session information. You will be prompted and asked which things you want to reset.
Resetting Configuration Options to Defaults
-reset-config
This option tells Source Insight to reset all optional settings in the configuration. This includes things like the color settings, styles, key bindings, and all options set on the Options menu.
Resetting the Display Layout
-reset-layout
This option tells Source Insight to reset the window layout to defaults.
130 Source Insight 4 User Guide