Spectre generate Options
The Spectre command line generate sub-command can generate files. It has the following syntax:
spectre generate <target type> [options]
The only available target type is a build file, which generates a build script. It has the following syntax:
spectre generate build <filename> [options]
The <filename> points to an existing data file. The <filename> can take various forms:
- If you set DI_PROJECT or pass --project as an argument, you can use a project path such as /data/sales.txt. This format always uses forward slashes regardless of the operating system.
- If you do not set DI_PROJECT and do not pass --project as an argument, you can use a file system path such as C:\di\project\sales\data\sales.txt, or use sales.txt if the current working directory is C:\di\project\sales\data.
For example:
spectre generate build /data/sales.txt
Enter spectre generate build -h to display the syntax and options as shown in the following table.
Spectre generate build Sub-command Options
Option | Description |
---|---|
--dataroot arg |
Set the path to the DiveLine server dataroot. For example: spectre generate build /data/sales.txt --dataroot c:\di\solution\dl-dataroot Instead of using this option, you can set the DI_HOME environment variable. See Setting Environment Variables. |
--project arg |
Set the project name. For example: spectre generate build /data/sales.txt --project sales Instead of using this option, you can set the DI_PROJECT environment variable. See Setting Environment Variables. |
--encoding arg |
Specify input encoding for text files. For example: spectre generate build /data/sales.txt --encoding ISO-8859-1 The resulting Build script includes the encoding= attribute. |
-l [ --limit-rows ] arg |
Limit the number of input rows. The default value is 100000. For example: spectre generate build /data/sales.txt --limit-rows 500 The Build script generated includes the limit-rows= attribute. |
-d [ --delimiter ] arg |
Set the field delimiter. For example: spectre generate build /data/sales.txt --delimiter "," The generated Build script includes the delimiter= attribute. NOTE: When no delimiter is specified, Spectre tries to determine the column delimiter on input text files. However, it does NOT cause the detected delimiter to be explicitly written into the generated Build script. |
--no-headers |
Do not treat the first row as a header row. |
--ignore-quotes |
Do not strip quotes. |
--no-trim |
Do not trim white space around values. The resulting Build script includes the attribute trim=false. |
--script-path arg |
Set the path for the generated Build script—be sure the folder exists in the project. For example: spectre generate build /data/sales.txt --script-path /build/sales.build If not set, the output defaults to the same directory as the data. |
--cbase-path arg |
Set a path for the cBase. For example: spectre generate build /data/sales.txt --cbase-path /cbases/sales.cbase If not set, the cBase is placed in the same directory as the Build script. |
-q [ --quiet ] |
Print only warnings and errors to the console. For example: spectre generate build /data/sales.txt --quiet When the command runs with this option, no timestamps or individual processes display; only warnings and errors are output to the console. If successful, only the command prompt displays. |
- When "spectre generate build" runs, it analyzes the input file and generates a plausible build script. When doing so, it might generate informative messages and warnings about the types of columns and include these messages as comments in the generated script. This might include a commented line with the "suggested" format configured. If so, you can un-comment the "suggested" line and then comment or remove the "incorrect assumption" or default line if appropriate.
- When running "spectre generate build" on text input that contains date columns, Spectre automatically makes those columns dates or periods, without a warning, generating, for example:
- column "Ship Date" type="date" format="YYYY-MM-DD"
- input-format="YYYY-M-D"
- Note that Spectre cannot tell whether you intend the dates to have padded months, days, or weeks. Therefore Spectre uses a permissive input format that allows both "2015-1-12" and "2015-01-12", but it uses the safer output format that pads those values to two digits.
- When running "spectre generate build" on text input that contains datetime columns, Spectre treats the columns as strings.
- Columns that contain numbers that might be dates, such as 20150112, generate warnings, and Spectre generates scripts that treat the values as numbers.
- When a column contains periods, Spectre assumes that the column is not using a custom calendar. If it sees values like "2015-01" it generates:
- column "YearMo" type="period" calendar="gregorian month" format="YYYY-MM"
- input-format="YYYY-M"
- If the data uses custom calendars, the generated script needs to be adjusted.
The following command assumes that the system PATH variable includes the location of the Spectre executable file.
spectre generate build --project PRs /data/folder_properties.txt
--dataroot c:\di\solution\dl-dataroot -d tab
--script-path /programs/folderprops.build
--cbase-path /cbases/folderprops.cbase
The file in the data folder is read as tab delimited text with a column header. The resulting Build script is written to the programs folder, while the cBase is written to the cbases folder.