Skip to content

Commit 47fd9d4

Browse files
rYamal4AXEPOH
authored andcommitted
DBTOOLS-869 added option for alt locations
1 parent 5d58569 commit 47fd9d4

9 files changed

Lines changed: 37 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- Added `--structure-file` parameter for parse mode, which allows specifying the path to a properties file with directory layout overrides for project export.
13+
1214
### Changed
1315

1416
### Fixed

CHANGELOG.ru.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
### Добавлено
1111

12+
- Добавлен параметр `--structure-file` для режима parse, позволяющий указать путь к properties-файлу с альтернативной структурой директорий объектов при экспорте проекта.
13+
1214
### Изменено
1315

1416
### Исправлено

src/main/java/org/pgcodekeeper/cli/CliArgs.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ enum CliMode {
243243
@Option(name = "--update-project", usage = "update-project")
244244
private boolean projUpdate;
245245

246+
@Option(name = "--structure-file", metaVar = CliArgsLocalizationsBundle.PATH, usage = "structure-file")
247+
private String structureFile;
248+
246249
@Option(name = "--graph-depth", metaVar = CliArgsLocalizationsBundle.N, usage = "graph-depth")
247250
private int graphDepth;
248251

@@ -485,6 +488,10 @@ public boolean isProjUpdate() {
485488
return projUpdate;
486489
}
487490

491+
public String getStructureFile() {
492+
return structureFile;
493+
}
494+
488495
public Collection<String> getGraphNames() {
489496
return Collections.unmodifiableCollection(graphNames);
490497
}
@@ -581,6 +588,7 @@ public CliArgs copy() {
581588
args.postFilePath = postFilePath;
582589
args.preFilePath = preFilePath;
583590
args.projUpdate = projUpdate;
591+
args.structureFile = structureFile;
584592
args.runOnDb = runOnDb;
585593
args.runOnTarget = runOnTarget;
586594
args.safeMode = safeMode;
@@ -676,8 +684,13 @@ private void checkParams() throws CmdLineException {
676684
if (runOnDb != null && !runOnDb.startsWith(URL_START_JDBC)) {
677685
badArgs(Messages.CliArgs_error_run_on_non_jdbc);
678686
}
679-
} else if (CliMode.PARSE == mode && outputTarget == null) {
680-
badArgs(Messages.CliArgs_error_argument_null.formatted("\"-o (--output)\"")); //$NON-NLS-1$
687+
} else if (CliMode.PARSE == mode) {
688+
if (outputTarget == null) {
689+
badArgs(Messages.CliArgs_error_argument_null.formatted("\"-o (--output)\"")); //$NON-NLS-1$
690+
}
691+
if (projUpdate && structureFile != null) {
692+
badArgs(Messages.CliArgs_error_structure_file_with_update);
693+
}
681694
}
682695
}
683696

@@ -711,6 +724,7 @@ private void checkModeParams() throws CmdLineException {
711724
badArgWithCorrectModes(!sourceLibs.isEmpty(), "--tgt-lib", CliMode.DIFF); //$NON-NLS-1$
712725
badArgWithCorrectModes(!sourceLibsWithoutPriv.isEmpty(), "--tgt-lib-no-priv", CliMode.DIFF); //$NON-NLS-1$
713726
badArgWithCorrectModes(projUpdate, "--update-project", CliMode.PARSE); //$NON-NLS-1$
727+
badArgWithCorrectModes(structureFile != null, "--structure-file", CliMode.PARSE); //$NON-NLS-1$
714728
badArgWithCorrectModes(!graphNames.isEmpty(), "--graph-name", CliMode.GRAPH); //$NON-NLS-1$
715729
badArgWithCorrectModes(DEFAULT_DEPTH != graphDepth, "--graph-depth", CliMode.GRAPH); //$NON-NLS-1$
716730
badArgWithCorrectModes(!graphFilterTypes.isEmpty(), "--graph-filter-object", CliMode.GRAPH); //$NON-NLS-1$

src/main/java/org/pgcodekeeper/cli/PgDiffCli.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ public void exportProject() throws IOException, InterruptedException {
5858
var newDbLoader = getDatabaseLoader(arguments.getNewSrc(),
5959
arguments.getTargetLibXmls(), arguments.getTargetLibs(), arguments.getTargetLibsWithoutPriv());
6060

61+
String structureFile = arguments.getStructureFile();
6162
PgCodeKeeperApi.exportToProject(arguments.getProvider(), null, newDbLoader,
62-
Path.of(arguments.getOutputTarget()), diffSettings);
63+
Path.of(arguments.getOutputTarget()), false,
64+
structureFile == null ? null : Paths.get(structureFile), diffSettings);
6365

6466
assertErrorsEmpty();
6567
}

src/main/java/org/pgcodekeeper/cli/localizations/CliArgsLocalizationsBundle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ protected Object[][] getContents() {
9595
{ "ignore-concurrent-modification", Messages.CliArgs_ignore_concurrent_modification }, //$NON-NLS-1$
9696
{ "db-type", Messages.CliArgs_db_type }, //$NON-NLS-1$
9797
{ "update-project", Messages.CliArgs_update_project }, //$NON-NLS-1$
98+
{ "structure-file", Messages.CliArgs_structure_file }, //$NON-NLS-1$
9899
{ "graph-depth", Messages.CliArgs_graph_depth }, //$NON-NLS-1$
99100
{ "graph-reverse", Messages.CliArgs_graph_reverse }, //$NON-NLS-1$
100101
{ "graph-name", Messages.CliArgs_graph_name }, //$NON-NLS-1$

src/main/java/org/pgcodekeeper/cli/localizations/Messages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class Messages {
3737
public static String CliArgs_error_run_on_non_jdbc;
3838
public static String CliArgs_error_source_dest;
3939
public static String CliArgs_error_source_null;
40+
public static String CliArgs_error_structure_file_with_update;
4041
public static String CliArgs_error_target_non_db;
4142
public static String CliArgs_error_wrong_db_type;
4243
public static String CliArgs_error_wrong_mode;
@@ -78,6 +79,7 @@ public class Messages {
7879
public static String CliArgs_src_lib_no_priv;
7980
public static String CliArgs_src_lib_xml;
8081
public static String CliArgs_stop_not_allowed;
82+
public static String CliArgs_structure_file;
8183
public static String CliArgs_target;
8284
public static String CliArgs_tgt_lib;
8385
public static String CliArgs_tgt_lib_no_priv;

src/main/resources/org/pgcodekeeper/cli/localizations/messages.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ CliArgs_error_source_dest = Please specify both SOURCE and DEST.
3737

3838
CliArgs_error_source_null = Please specify SOURCE.
3939

40+
CliArgs_error_structure_file_with_update = --structure-file cannot be used with --update-project.
41+
4042
CliArgs_error_target_non_db = Script can be applied only to database.
4143

4244
CliArgs_error_wrong_db_type = %s cannot be used with --db-type %s option
@@ -117,6 +119,8 @@ CliArgs_src_lib_xml = add xml with libraries to source\nspecify multiple times t
117119

118120
CliArgs_stop_not_allowed = exit with an error when --allowed-object hides a dependency statement from the script
119121

122+
CliArgs_structure_file = path to a properties file with directory layout overrides for parse mode
123+
120124
CliArgs_target = destination for schema changes (diff mode only)
121125

122126
CliArgs_tgt_lib = add library to destination\nspecify multiple times to use several libraries

src/main/resources/org/pgcodekeeper/cli/localizations/messages_ru_RU.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ CliArgs_error_source_dest = \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u04
3737

3838
CliArgs_error_source_null = \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0443\u043A\u0430\u0436\u0438\u0442\u0435 SOURCE.
3939

40+
CliArgs_error_structure_file_with_update = --structure-file \u043D\u0435\u043B\u044C\u0437\u044F \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0441 --update-project.
41+
4042
CliArgs_error_target_non_db = \u0421\u043A\u0440\u0438\u043F\u0442 \u043C\u043E\u0436\u043D\u043E \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u043A \u0431\u0430\u0437\u0435 \u0434\u0430\u043D\u043D\u044B\u0445.
4143

4244
CliArgs_error_wrong_db_type = %s \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D \u0441 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u043C --db-type %s
@@ -117,6 +119,8 @@ CliArgs_src_lib_xml = \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C xml \u044
117119

118120
CliArgs_stop_not_allowed = \u0432\u044B\u0445\u043E\u0434\u0438\u0442\u044C \u0441 \u043E\u0448\u0438\u0431\u043A\u043E\u0439, \u043A\u043E\u0433\u0434\u0430 --allowed-object \u0441\u043A\u0440\u044B\u0432\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0439 \u043E\u0431\u044A\u0435\u043A\u0442 \u0438\u0437 \u0441\u043A\u0440\u0438\u043F\u0442\u0430
119121

122+
CliArgs_structure_file = \u043F\u0443\u0442\u044C \u043A properties-\u0444\u0430\u0439\u043B\u0443 \u0441 \u0430\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u043E\u0439 \u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u043E\u0439 \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0439 \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0434\u043B\u044F \u0440\u0435\u0436\u0438\u043C\u0430 parse
123+
120124
CliArgs_target = \u043F\u0440\u0438\u0435\u043C\u043D\u0438\u043A \u0434\u043B\u044F \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439 \u0441\u0445\u0435\u043C\u044B (\u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u0440\u0435\u0436\u0438\u043C\u0435 \u0441\u0440\u0430\u0432\u043D\u0435\u043D\u0438\u044F)
121125

122126
CliArgs_tgt_lib = \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0443 \u043A \u043F\u0440\u0438\u0435\u043C\u043D\u0438\u043A\u0443\n\u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0430\u0437, \u0447\u0442\u043E\u0431\u044B \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A

src/test/resources/org/pgcodekeeper/cli/usage_check.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ Usage
135135
--stop-not-allowed : exit with an error when
136136
--allowed-object hides a dependency
137137
statement from the script
138+
--structure-file <path> : path to a properties file with
139+
directory layout overrides for parse
140+
mode
138141
--target (-t) <path or JDBC> : destination for schema changes (diff
139142
mode only)
140143
--tgt-lib <path or JDBC> : add library to destination

0 commit comments

Comments
 (0)