Command Line Reference

MapPrep

Command Line Reference

 

To generate code with CodeGen a developer goes to the operating system command prompt in an appropriately configured environment and issues codegen commands.

As a minimum the developer must use the -t option to specify the name of at least one template file to be used, and in almost all situations the -s option is also used to specify one or more repository structures to be processed.

There are several other command line options documented below. Some of the main ones are the -r option which causes any existing output files to be replaced, and the -v option which produces various information messages to be displayed as CodeGen generates code.

For example, a developer might use a command like this:

C:> codegen -t data_class -s customer -r -v

This command would cause CodeGen to create an output file based on the code defined in the template file named data_class.tpl and using information from the repository structure named CUSTOMER. If the output file already exists then it will be overwritten, and verbose messages will be displayed.

  codegen <options>

Commonly Used Command Line Options

These options are used almost every time CodeGen is used:

    -s structure[.group] [...] | *

Structure(s) to process. You must specify the name of at least one structure and may optionally specify multiple structure names separated by spaces. Alternatively you can specify the * wild-card to indicate that all structures are to be processed. It is also possible to generate a "pseudo structure" based on the fields within an implicit group within a structure.

In-process API equivalent: CodeGenTask.Structures property (List<String>).

    -t [*]template [...]

Template(s) to process. You must specify at least one template name, and may optionally specify multiple template names separated by spaces. Alternatively you can use the wild-card character * to specify that multiple templates should be processed (e.g. database*) or use the * wild-card alone to indicate that all templates should be processed.

In-process API equivalent: CodeGenTask.Templates property (List<String>).

    -r

Replace existing files.  By default existing files are not replaced.

In-process API equivalent: CodeGenTask.ReplaceFiles property (Boolean) 

Other Command Line Options

These options can be used to modify how CodeGen works:

    -a alias [...]]

Structure aliases. A structure alias is an alternate name to be used to represent a structure. If -a is used then you must specify at least one alias name, and may optionally specify multiple alias names separated by spaces, up to but not exceeding the number of structure names that have been specified via the -s option.

In-process API equivalent: CodeGenTask.Aliases property (List<String>).

    -ba|d|n

Override default button loop processing rules.

-ba    Always use the default buttons defined in DefaultButtons.xml.
-bd    Never use the default buttons defined in DefaultButtons.xml.
-bn    Never load any buttons (DefaultButtons.xml or window script).

In-process API equivalents:

-ba    CodeGenTask.AlwaysLoadDefaultButtons property (Boolean)
-bd    CodeGenTask.NeverLoadDefaultButtons property (Boolean)
-bn    CodeGenTask.NeverLoadAnyButtons property (Boolean)

    -c

Continue processing after errors. If multiple templates, files or tasks are being processed then this option allows code generation to continue even though one template/structure combination has generated an error.

In-process API equivalent: CodeGenTaskSet.ContinueAfterError property (Boolean)

    -cdm <filespec>

Specifies that custom data mappings are loaded from an XML file. Refer to Customizing Data Type Mappings in the docs for more info.

In-process API equivalent: CodeGenTaskSet.DataMappingsFile property (String)

    -ch <pixels>

Overrides the default number of pixels per row to be used when calculating pixel coordinates using tokens like <FIELD_PIXEL_ROW>.

In-process API equivalent: CodeGenTask.CharacterHeight property (int)

    -checkversion [interval]

Checks whether there is a later version of CodeGen available for download. This option requires Internet connectivity. If you do not specify an interval value then CodeGen will perform an immediate check for available updates and will report the result. If you specify an interval of 1 or more (days) then CodeGen will automatically check for available updates after that many days has expired since the previous update check; the update check will take place the next time you use CodeGen and you will see messages as the update check takes place. To cancel a previously scheduled automatic update checks specify an interval of 0.

    -cw <pixels>

Overrides the default number of pixels per character to be used when calculating pixel coordinates using tokens like <FIELD_PIXEL_WIDTH>.

In-process API equivalent: CodeGenTask.CharacterWidth property (int)

    -d

Debug mode. Displays additional information during processing; more than verbose mode.

In-process API equivalent: CodeGenTaskSet.LoggingLevel property (use LoggingLevel.Debug)

    -database SQLServer | MySQL | PostgreSQL

Database type. Specifies the relational database that code is being generated for by altering the SQL data types emitted by the <FIELD_SQLTYPE> token. The default database type is SQLServer, unless altered by the CODEGEN_DATABASE_TYPE environment variable.

In-process API equivalent: CodeGenTaskSet.DatabaseType property

          -define <identifier> [<identifier>...]

Defines one or more identifiers, the presence of which can be tested in template files to implement conditional processing.

In-process API equivalent: CodeGenTaskSet.Defines property (List<string>)

    -docs

Displays the CodeGen documentation, either the Windows help file if the documentation is installed locally, or the on-line documentation if not. Bear in mind that the on-line documentation will always be for the latest version of CodeGen, which may be later than the version that you are currently running.

In-process API equivalent: None

    -dt

Debug tree. Creates log files containing the internal results of the code tokenization and parsing phases.

In-process API equivalent:  CodeGenTaskSet.LogTokenizerResults property (Boolean)

    -e

Echo the command line used to start CodeGen.  This can be useful when starting CodeGen from a batch file in which echo has been disabled but where you want to see a representation of the commands that are being executed.

In-process API equivalent:  CodeGenTaskSet.EchoCommands property (Boolean)

    -f [o|l|t|r|w]

Override default field loop processing rules.

          -f o   Include overlay fields.
          -f l   DO NOT exclude fields which are "Excluded by Language".
          -f t   Exclude fields which are "Excluded by Toolkit".
          -f r   Exclude fields which are "Excluded by ReportWriter".
          -f w   Exclude fields which are "Excluded by Web".

In-process API equivalents:

          -f o   CodeGenTask.IncludeOverlayFields property (Boolean)
          -f l   CodeGenTask.IgnoreExcludeLanguage property (Boolean)
          -f t   CodeGenTask.HonorExcludeToolkit property (Boolean)
          -f r   CodeGenTask.HonorExcludeReportWriter property (Boolean)
          -f w   CodeGenTask.HonorExcludeWeb property (Boolean)

    -fields [str.]field [[str.]field] ...

Creates a field subset based on the list of fields listed on the command line. When processing multiple structures concurrently (via the -ms or -file options) field names may be prefixed with the appropriate structure names.

In-process API equivalent: CodeGenTask.SubsetFields property (List<Tuple<String, String>>)

    -file filename

Repository file name to process. This option causes all structures that are assigned to the file definition to be available for use when processing templates. The end result is similar to specifying multiple structures with -s and using the -ms option.

In-process API equivalent: CodeGenTask.RepositoryFile property (String).

    -fo file [...]

File Overrides. Allows you to specify which repository file definition is used for each structure being processing. This option is useful if the structure that you are using is assigned to multiple files because by default CodeGen will use the first assigned file. When the -fo option is used you must specify at least one repository file definition name, and have the option of specifying file overrides for multiple structures, up to but not exceeding the number of structures specified via the -s option.

In-process API equivalent: CodeGenTask.FileOverrides property (List<String>).

    -g f|r|i

Override default group field name prefix rules

          -g f   Don't prefix group fields with group name.
          -g i   Don't expand implicit groups to individual fields.
          -g r   Don't use repository group field prefix.

In-process API equivalents:

          -g f   CodeGenTask.GroupFieldNoGroupPrefix property (Boolean)
          -g i   CodeGenTask.GroupNoExpand property (Boolean)
          -g r   CodeGenTask.GroupFieldNoRpsPrefix property (Boolean)

    -h | -?

Display command-line help information.

In-process API equivalent: None

    -i inpdir

Input file directory containing templates. Defaults to the current directory, or the directory specified with the CODEGEN_TPLDIR environment variable. You can specify a full or relative path, or a logical name followed by a colon (e.g. TPL:).

In-process API equivalent: CodeGenTaskSet.TemplateFolder property (String) or CodeGenTask.TemplateFolder property (String)

    -lf

List Files. Lists the names of any files generated when not running in verbose or debug logging modes.

In-process API equivalent:  CodeGenTaskSet.ListGeneratedFiles property (Boolean)

    -ms

Multiple Structures. Specifies that the structures that follow the -s command line option should all be available to templates being processed, at the same time.

In-process API equivalent: CodeGenTask.MultipleStructures property (Boolean).

    -mw

Multi-write a file if the same file is generated more than once.

In-process API equivalent: CodeGenTask.MultiWriteFiles property (Boolean)

    -n namespace

The namespace to use when replacing the <NAMESPACE> token. Codegen will determine the default namespace using the environment variable SYNDEFNS, and this can be overridden with the -n option.

In-process API equivalent: CodeGenTask.Namespace property (String)

    -nf

Don't append sub-folder to namespace. If a template file uses the <CODEGEN_FOLDER> token to specify that files created from the template should be created in a sub-folder below the main output folder, then by default, if a namespace is also being used, the name of the sub-folder is appended to the namespace. This option overrides that behavior.

In-process API equivalent: CodeGenTask.DontAppendFolderToNamespace property (Boolean)

    -o outdir

Output directory. Defaults to the current directory, or the directory specified with the CODEGEN_OUTDIR environment variable. You can use a full or relative path, or a logical followed by a colon (e.g. SRC:).

In-process API equivalent: CodeGenTaskSet.OutputFolder property (String) or CodeGenTask.OutputFolder property (String)

    -opk <keyNumber>

Overrides the key that is used when a primary key block (<PRIMARY_KEY>) is used. By default the first key defined by the structure is used.

In-process API equivalent: CodeGenTask.PrimaryKeyNumber property (int)

    -prefix <name>

When using the <FIELD_NAME> token, prefix field names with <name>. Useful with repository .include with the optional prefix= qualifier.

In-process API equivalent: CodeGenTask.FieldPrefix property (String)

    -rps <mainfile> <textfile>

Allows the repository main and text files to be used to be specified on the command line, overriding other mechanisms for repository selection such as RPSDAT, RPSMFIL and RPSTFIL environment variables.

In-process API equivalent: CodeGenTask.RepositoryMainFile and CodeGenTask.RepositoryTextFile properties (String)

    -subset name

Subset of fields to use. Specify subsets in field user text strings with @SUB=name; syntax. This option is only valid when processing a single repository structure.

In-process API equivalent: CodeGenTask.Subset property (String).

    -tf

Allow template defined folders. From CodeGen V5.0.2 it has been possible for template files to define the name of a sub folder (below the main output folder) where files generated from the template should be created. This is done by using the file header token <CODEGEN_FOLDER>. This option enables this functionality.

In-process API equivalent: CodeGenTask.AllowTemplateFolder property (Boolean)

    -u usertokenfile

User defined token file. Specify a full or relative file spec of the file that contains user defined token definitions. The file spec can include Synergy logical names.

In-process API equivalent: CodeGenTask.UserTokenFile property (String)

    -ut name=value [...]

User defined tokens specified via the command line. You must specify at least one name=value, and may optionally specify multiple name=value pairs separated by spaces. If spaces exist in the name or value then you should enclose the entire name=value pair in quotation marks.

In-process API equivalent: CodeGenTask.UserTokens property (List<UserToken>)

    -utpp

Treat user-defined tokens as preprocessor tokens, expanding them out to their constituent parts during the initial tokenization phase. This enables other tokens to be embedded in the values of user-defined tokens.

    -v

Verbose mode. Displays additional information during processing; not as much as debug (-d) mode.

In-process API equivalent: CodeGenTaskSet.LoggingLevel property (use LoggingLevel.Verbose)

    -version

Display the version of CodeGen that you are running.

    -w <wscfile>[#n]

Process input from a UI Toolkit Window script file. By default the fields and buttons collection will be based on the first input window found in the script file, but this can be overridden using the #n qualifier, which specifies either a 1-based input window number or the name of the input window to process.

In-process API equivalent: CodeGenTask.WindowScript property (String)

    -wn

When processing input from a UI Toolkit Window script file this option prevents script file input window field attributes from being used to override repository field attributes. This allows you to generate code based on only the fields listed in an input window, but using only the repository field definitions.

In-process API equivalent: CodeGenTask.IgnoreScriptFieldAttributes property (Boolean)

    -ws <wscfile>

Window script selection list processing. When this option is used CodeGen will examine any fields which have selection windows specified and will attempt to populate the field selections property based on the selection items defined in the named selection window.

In-process API equivalent: CodeGenTask.SelectionWindowScript property (String)     

Processing a Synergy Method Catalog

These options are used to perform code generation based on metadata contained in a Synergy Method Catalog XML export file.

    -smc <smcXmlFile>

Synergy method catalog XML file to use. When using this option you may not use the -s option to specify specific structures to process. If you also specify the -interface option then only that interface will be processed, and you may not use interface loops in your template files. If you do not specify the -interface option then you MUST use an interface loop in your template file.

In-process API equivalent: None.

    -interface <interfaceName>

The name of the interface in the Synergy Method Catalog XML file that you wish to generate code for. This option is only valid in conjunction with the -smc option, refer to the details of that option above for additional information.

In-process API equivalent: None.

Advanced Debugging Options

These options are intended for use by CodeGen developers and are not particularly useful when using CodeGen to generate code.

    -attach

Intended for use by CodeGen developers, this option causes CodeGen to wait for a key press at the very beginning of processing. This makes it possible to attach an external debugger to the process before processing begins.

In-process API equivalent:  None

    -debug

Developer debug mode (displays extensive debugging information).

In-process API equivalent:  CodeGenTaskSet.LoggingLevel property (use LoggingLevel.DeveloperDebug)

    -pause

Causes CodeGen to wait for a key press at the very end of processing. This makes it possible to perform final tasks before a debugging environment terminates.

In-process API equivalent:  None

          -time

Displays the elapsed time taken to process the command.

In-process API equivalent:  None

 

 


Copyright © 2018  Synergex International, Inc.