You can automate code formatting using the command line.
1. Start Windows Command Prompt (CMD).
Note
To run the Command Line in Windows 10:
From the Desktop Mode
- Move the mouse cursor to the exact lower left corner until the desktop shortcuts menu appears.
- Right-click to see the shortcut menu and than click Run.
From the Charms Bar
- Move your mouse to the upper right corner until the Charms Bar appears.
- Select Apps from the list and type run in the search box.
- Click Run from the search results.
Use Windows + R Shortcut Keys
- In desktop mode, press the Windows + R keys, to show the Run command line.
- In the window that opens, type cmd and press Enter.
2. Type a path to the dbforgepostgresql.com file located in the dbForge Studio for PostgreSQL installation folder on your PC, and then press SPACEBAR.
"C:\Program Files\Devart\dbForge Studio for PostgreSQL\dbforgepostgresql.com"
Note
The path to the executable file will differ depending on how you have installed the Studio - as a standalone tool or as part of the dbForge Edge bundle. Make sure that you have specified a correct path. If you have installed the Studio as part of dbForge Edge, change the path accordingly:
C:\Program Files\Devart\dbForge Edge\dbForge Studio for PostgreSQL>dbforgepostgresql.com
Note
To change the disk drive for the installation folder, in the Command Prompt, use the cd command.
4. Specify the operation you want to perform (code formatting) and the required parameters and arguments:
/formatsql /connection:"User Id=yourusername;Host=JordanSanders;Port=5432;Database=postgres;Unicode=True;Connection Timeout=15;Default Command Timeout=30;Integrated Security=False" /profile:"D:\Custom profile 1.xml" /sourcefile:D:\profiles\userprofile.sql /outputfile:D:\profiles\new_profile.sql
Tip
To get quick help on the arguments available in the command line, type the following:
dbforgepostgresql.com /?
5. Press Enter to run the process.
Argument | Usage and Action |
---|---|
/argfile | Usage: /argfile:<path> Path to the command line arguments file. The options specified in the command line have higher priority than the options which were given in the file. |
/activate | Activate the product using the activation key. |
/connection | Usage: /connection:<connection_string> Specify the connection string. |
/deactivate | Deactivate the product. |
/encoding | Usage: /encoding:<codepage|encoding name> Specify the encoding that should be applied to open and save files. |
/errormode | Usage: /errormode:<ignore|abort> Specify the application behavior when an error is encountered: ignore - to ignore all errors; abort - to cancel execution if any error occurs. |
/exitcodes | The list of possible exit codes that can be returned by the command-line process. |
/filextension | Usage: /filextension:*.<sql|prc|txt|...> Specify the extension of the source folder files that will be formatted. The .sql extension is selected by default. |
/formatsql | Format SQL files with a specified profile. |
/log | Usage /log:<filepath> Generate a formatting log file in the specified directory. |
/outputfile | Usage: /outputfile:<path> Specify the path to an output file where the formatting results of the source file will be saved (in this case, the source file is saved without changes). If the parameter is not specified, the formatting results will be saved in the source file. |
/outputfolder | Usage: /outputfolder:<path> Specify the path to an output folder where the source folder files with the formatting results will be saved. The files from the source folder will not be changed. If the parameter is not specified, the formatting results will be saved in the source folder files. |
/password | Usage: /password:<yourpassword> Specify the server password. This overrides the password specified in the connection string. |
/profile | Usage: /profile:<path>|<profile name> Specify the path to the file that contains formatting options settings or a predefined profile name. If the parameter is not specified, default formatting options settings will be applied. |
/quiet (/q) | Hide all messages in the console mode. |
/sourcefile | Usage: /sourcefile:<path> Specify the source SQL file to be formatted. |
/sourcefolder | Usage: /sourcefolder:<path> Specify the path to the folder where the files for formatting are located. |
/treatwarningaserror | Usage: /treatWarningAsError:[Yes|No] Yes: Treat all warnings as errors; further behavior is determined by the errormode option. No: Do not treat all warning errors and execute with warning messages. |
Exit code | Description | Additional information |
---|---|---|
0 | Success | The operation has been completed without errors. |
1 | Unhandled exception | Unhandled exception. See the log for more details. |
10 | Command line usage error | The command line was used incorrectly. For example, an incorrect flag, or incorrect syntax may have been used. |
11 | Illegal argument duplication | Some arguments may not appear more than once in a command line. For example, /arg2 depends on /arg1 but you have specified /arg2 without specifying /arg1, or /arg2 cannot be used with /arg1, but you have used them both. |
20 | Trial expired | Software trial period has expired, or the product has not been activated. |
40 | Server connection fail | Server connection failed. |
104 | High-level parser error | High-level errors were encountered while parsing a scripts folder. |
105 | Resource unavailable | The file is missing. |